class SassDebugNode in Sassy 7.3
Same name and namespace in other branches
- 7 phamlp/sass/tree/SassDebugNode.php \SassDebugNode
SassDebugNode class. Represents a Sass @debug or @warn directive. @package PHamlP @subpackage Sass.tree
Hierarchy
- class \SassNode
- class \SassDebugNode
Expanded class hierarchy of SassDebugNode
File
- phpsass/
tree/ SassDebugNode.php, line 18
View source
class SassDebugNode extends SassNode {
const IDENTIFIER = '@';
const MATCH = '/^@(?:debug|warn)\\s+(.+?)\\s*;?$/';
const MESSAGE = 1;
/**
* @var string the debug/warning message
*/
private $message;
/**
* @var array parameters for the message;
* only used by internal warning messages
*/
private $params;
/**
* @var boolean true if this is a warning
*/
private $warning;
/**
* SassDebugNode.
* @param object source token
* @param mixed string: an internally generated warning message about the
* source
* boolean: the source token is a @debug or @warn directive containing the
* message; True if this is a @warn directive
* @param array parameters for the message
* @return SassDebugNode
*/
public function __construct($token, $message = false) {
parent::__construct($token);
if (is_string($message)) {
$this->message = $message;
$this->warning = true;
}
else {
preg_match(self::MATCH, $token->source, $matches);
$this->message = $matches[self::MESSAGE];
$this->warning = $message;
}
}
/**
* Parse this node.
* This raises an error.
* @return array An empty array
*/
public function parse($context) {
if (!$this->warning || $this->root->parser->quiet === false) {
set_error_handler(array(
$this,
'errorHandler',
));
trigger_error($this->warning ? $this
->interpolate($this->message, $context) : $this
->evaluate($this->message, $context)
->toString());
restore_error_handler();
}
return array();
}
/**
* Error handler for degug and warning statements.
* @param int Error number
* @param string Message
*/
public function errorHandler($errno, $message) {
echo '<div style="background-color:#ce4dd6;border-bottom:1px dashed #88338d;color:white;font:10pt verdana;margin:0;padding:0.5em 2%;width:96%;"><p style="height:auto;margin:0.25em 0;padding:0;width:100%;"><span style="font-weight:bold;">SASS ' . ($this->warning ? 'WARNING' : 'DEBUG') . ":</span> {$message}</p><p style=\"margin:0.1em;padding:0;padding-left:0.5em;width:100%;\">{$this->filename}::{$this->line}</p><p style=\"margin:0.1em;padding:0;padding-left:0.5em;width:100%;\">Source: {$this->source}</p></div>";
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SassDebugNode:: |
private | property | ||
SassDebugNode:: |
private | property | only used by internal warning messages | |
SassDebugNode:: |
private | property | ||
SassDebugNode:: |
public | function | Error handler for degug and warning statements. | |
SassDebugNode:: |
constant | |||
SassDebugNode:: |
constant | |||
SassDebugNode:: |
constant | |||
SassDebugNode:: |
public | function | Parse this node. This raises an error. | |
SassDebugNode:: |
public | function |
SassDebugNode. Overrides SassNode:: |
|
SassNode:: |
public | property | ||
SassNode:: |
public | property | 1 | |
SassNode:: |
public | property | ||
SassNode:: |
public | property | ||
SassNode:: |
public | function | Adds a child to this node. | |
SassNode:: |
public | function | Adds a warning to the node. | |
SassNode:: |
public | function | Evaluates a SassScript expression. | |
SassNode:: |
public | function | Returns the node's children | |
SassNode:: |
public | function | Returns the debug_info option setting for this node | |
SassNode:: |
public | function | Returns the filename for this node | |
SassNode:: |
public | function | Returns the last child node of this node. | |
SassNode:: |
public | function | Returns the level of this node. | |
SassNode:: |
public | function | Returns the line number for this node | |
SassNode:: |
public | function | Returns the line_numbers option setting for this node | |
SassNode:: |
public | function | Returns the node's parent | |
SassNode:: |
public | function | Returns the Sass parser. | |
SassNode:: |
public | function | Returns the property syntax being used. | |
SassNode:: |
public | function | Returns the renderer. | |
SassNode:: |
public | function | Returns the SassScript parser. | |
SassNode:: |
public | function | Returns the source for this node | |
SassNode:: |
public | function | Returns the render style of the document tree. | |
SassNode:: |
public | function | Returns vendor specific properties | |
SassNode:: |
public | function | Returns a value indicating if this node has children | |
SassNode:: |
public | function | Return a value indicating if this node has a parent | |
SassNode:: |
public | function | Returns a value indicating whether this node is in a directive | |
SassNode:: |
public | function | Returns a value indicating whether this node is in a SassScript directive | |
SassNode:: |
public | function | Replace interpolated SassScript contained in '#{}' with the parsed value. | |
SassNode:: |
public static | function | Returns a value indicating if the token represents this type of node. | 9 |
SassNode:: |
public | function | Returns a value indicating if this node is a child of the passed node. This just checks the levels of the nodes. If this node is at a greater level than the passed node if is a child of it. | |
SassNode:: |
public | function | Parse the children of the node. | |
SassNode:: |
public | function | Resets children when cloned | |
SassNode:: |
public | function | Getter. | |
SassNode:: |
public | function | Setter. |