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, mixin, and function definitions.
The lexical environment for SassScript.
def caller
-
(Environment?)
-
def caller @caller || (@parent && @parent.caller) end
def content
-
(Environment?)
-
def content @content || (@parent && @parent.content) end
def inherited_hash(name)
Note: when updating this,
def inherited_hash(name) class_eval <<RUBY, __FILE__, __LINE__ + 1 def #{name}(name) _#{name}(name.tr(UNDERSCORE, DASH)) end def _#{name}(name) (@#{name}s && @#{name}s[name]) || @parent && @parent._#{name}(name) end protected :_#{name} def set_#{name}(name, value) name = name.tr(UNDERSCORE, DASH) @#{name}s[name] = value unless try_set_#{name}(name, value) end def try_set_#{name}(name, value) @#{name}s ||= {} 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}s[name.tr(UNDERSCORE, DASH)] = value end end
def initialize(parent = nil)
-
parent
(Environment
) -- See \{#parent}
def initialize(parent = nil) @parent = parent end
def options
-
({Symbol => Object})
-
def options @options || parent_options || {} end
def parent_options
def parent_options @parent_options ||= @parent && @parent.options end