Class: Sass::Environment

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

Overview

The lexical environment for SassScript. This keeps track of variable, mixin, and function 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, options = nil) ⇒ Environment

Returns a new instance of Environment.

Parameters:



28
29
30
31
# File 'lib/sass/environment.rb', line 28

def initialize(parent = nil, options = nil)
  @parent = parent
  @options = options || (parent && parent.options) || {}
end

Instance Attribute Details

#callerEnvironment?

The environment of the caller of this environment's mixin or function.

Returns:



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

def caller
  @caller || (@parent && @parent.caller)
end

#contentEnvironment?

The content passed to this environmnet. This is naturally only set for mixin body environments with content passed in.

Returns:



42
43
44
# File 'lib/sass/environment.rb', line 42

def content
  @content || (@parent && @parent.content)
end

#options (readonly)

Returns the value of attribute options.



21
22
23
# File 'lib/sass/environment.rb', line 21

def options
  @options
end

#parentEnvironment (readonly)

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

Returns:



20
21
22
# File 'lib/sass/environment.rb', line 20

def parent
  @parent
end