You are here

public function SassContext::getVariable in Sassy 7

Same name and namespace in other branches
  1. 7.3 phpsass/tree/SassContext.php \SassContext::getVariable()

* Returns a variable defined in this context *

Parameters

string name of variable to return: * @return string the variable * @throws SassContextException if variable not defined in this context

File

phamlp/sass/tree/SassContext.php, line 79

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 (isset($this->variables[$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 {what}: {name}', array('{what}'=>'Variable', '{name}'=>$name), $this->node);
    return new SassBoolean('false');
  }
}