Class: Sass::Environment

Inherits:
Object show all
Defined in:
lib/sass/environment.rb

Overview

The lexical environment for SassScript. This keeps track of variable and mixin definitions.

A new environment is created for each level of Sass nesting. This allows variables to be lexically scoped. The new environment refers to the environment in the upper scope, so it has access to variables defined in enclosing scopes, but new variables are defined locally.

Environment also keeps track of the Engine options so that they can be made available to Script::Functions.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent = nil) ⇒ Environment

Returns a new instance of Environment.

Parameters:



22
23
24
25
26
27
28
# File 'lib/sass/environment.rb', line 22

def initialize(parent = nil)
  @vars = {}
  @mixins = {}
  @parent = parent

  set_var("important", Script::String.new("!important")) unless @parent
end

Instance Attribute Details

#optionsHash<Symbol, Object>

The options hash. See the Sass options documentation.

Returns:



34
35
36
# File 'lib/sass/environment.rb', line 34

def options
  @options || (parent && parent.options) || {}
end

#parentEnvironment (readonly)

The enclosing environment, or nil if this is the global environment.

Returns:



18
19
20
# File 'lib/sass/environment.rb', line 18

def parent
  @parent
end