PHP Class SassContext

Defines the context that the parser is operating in and so allows variables to be scoped. A new context is created for Mixins and imported files.
Exibir arquivo Open project: richthegeek/phpsass Class Usage Examples

Public Properties

Property Type Description
$content tree representing any contextual content.
$functions mixins defined in this context
$mixins mixins defined in this context
$node the node being processed
$parent enclosing context
$variables variables defined in this context

Public Methods

Method Description
__construct ( $parent = null ) : SassContext SassContext constructor.
addFunction ( string $name, mixed $function ) : SassFunctionDefinitionNode Adds a function
addMixin ( string $name, mixed $mixin ) : SassMixinDefinitionNode Adds a mixin
getContent ( )
getFunction ( string $name ) : SassFunctionDefinitionNode Returns a function
getMixin ( string $name ) : SassMixinDefinitionNode Returns a mixin
getVariable ( string $name ) : string Returns a variable defined in this context
hasFunction ( string $name ) : boolean Returns a boolean wether this function exists
hasVariable ( string $name ) : boolean Returns a value indicating if the variable exists in this context
merge ( ) Makes variables and mixins from this context available in the parent context.
setVariable ( string $name, sassLiteral $value ) : SassContext Sets a variable to the given value
setVariables ( $vars )

Method Details

__construct() public method

SassContext constructor.
public __construct ( $parent = null ) : SassContext
return SassContext

addFunction() public method

Adds a function
public addFunction ( string $name, mixed $function ) : SassFunctionDefinitionNode
$name string name of function
$function mixed
return SassFunctionDefinitionNode the function

addMixin() public method

Adds a mixin
public addMixin ( string $name, mixed $mixin ) : SassMixinDefinitionNode
$name string name of mixin
$mixin mixed
return SassMixinDefinitionNode the mixin

getContent() public method

public getContent ( )

getFunction() public method

Returns a function
public getFunction ( string $name ) : SassFunctionDefinitionNode
$name string name of function to return
return SassFunctionDefinitionNode the mixin

getMixin() public method

Returns a mixin
public getMixin ( string $name ) : SassMixinDefinitionNode
$name string name of mixin to return
return SassMixinDefinitionNode the mixin

getVariable() public method

Returns a variable defined in this context
public getVariable ( string $name ) : string
$name string name of variable to return
return string the variable

hasFunction() public method

Returns a boolean wether this function exists
public hasFunction ( string $name ) : boolean
$name string name of function to check for
return boolean

hasVariable() public method

Returns a value indicating if the variable exists in this context
public hasVariable ( string $name ) : boolean
$name string name of variable to test
return boolean true if the variable exists in this context, false if not

merge() public method

Note that if there are variables or mixins with the same name in the two contexts they will be set to that defined in this context.
public merge ( )

setVariable() public method

Sets a variable to the given value
public setVariable ( string $name, sassLiteral $value ) : SassContext
$name string name of variable
$value sassLiteral value of variable
return SassContext

setVariables() public method

public setVariables ( $vars )

Property Details

$content public_oe property

tree representing any contextual content.
public $content

$functions public_oe property

mixins defined in this context
public $functions

$mixins public_oe property

mixins defined in this context
public $mixins

$node public_oe property

the node being processed
public $node

$parent public_oe property

enclosing context
public $parent

$variables public_oe property

variables defined in this context
public $variables