class Sass::Environment
so that they can be made available to {Sass::Script::Functions}.
Environment also keeps track of the {Engine} options
but new variables are defined locally.
so it has access to variables defined in enclosing scopes,
The new environment refers to the environment in the upper scope,
This allows variables to be lexically scoped.
A new environment is created for each level of Sass nesting.
This keeps track of variable and mixin definitions.
The lexical environment for SassScript.
def inherited_hash(name)
Note: when updating this,
def inherited_hash(name) class_eval <<RUBY, __FILE__, __LINE__ + 1 def #{name}(name) @#{name}s[name] || @parent && @parent.#{name}(name) end def set_#{name}(name, value) @#{name}s[name] = value unless try_set_#{name}(name, value) end def try_set_#{name}(name, value) if @#{name}s.include?(name) @#{name}s[name] = value true elsif @parent @parent.try_set_#{name}(name, value) else false end end protected :try_set_#{name} def set_local_#{name}(name, value) @#{name}s[name] = value end end
def initialize(parent = nil)
-
parent
(Environment
) -- See \{#parent}
def initialize(parent = nil) @vars = {} @mixins = {} @parent = parent set_var("important", Script::String.new("!important")) unless @parent end
def options
-
({Symbol => Object})
-
def options @options || (parent && parent.options) || {} end