You are here

public function SassContext::getVariable in Sassy 7.3

Same name and namespace in other branches
  1. 7 phamlp/sass/tree/SassContext.php \SassContext::getVariable()

Returns a variable defined in this context

Parameters

string name of variable to return:

Return value

string the variable

Throws

SassContextException if variable not defined in this context

File

phpsass/tree/SassContext.php, line 127

Class

SassContext
SassContext class. 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. @package PHamlP @subpackage Sass.tree

Code

public function getVariable($name) {
  $name = str_replace('-', '_', $name);
  if ($this
    ->hasVariable($name)) {
    return $this->variables[$name];
  }
  elseif (!empty($this->parent)) {
    return $this->parent
      ->getVariable($name);
  }
  else {

    // Return false instead of throwing an exception.
    // throw new SassContextException('Undefined Variable: ' . $name, $this->node);
    return new SassBoolean('false');
  }
}