Class: Sass::Environment
- Inherits:
-
Object
- Object
- Sass::Environment
- Defined in:
- /var/www/sass-pages/.sass/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 Sass::Script::Functions.
Instance Attribute Summary
- - (Environment?) caller The environment of the caller of this environment’s mixin or function.
- - (Environment?) content The content passed to this environmnet.
- - options readonly Returns the value of attribute options.
- - (Environment) parent readonly The enclosing environment, or nil if this is the global environment.
Instance Method Summary
- - (Sass::Callable) function(name) Gets a function from this Environment or one of its #parents.
- - (Environment) initialize(parent = nil, options = nil) constructor A new instance of Environment.
- - (Sass::Callable) mixin(name) Gets a mixin from this Environment or one of its #parents.
- - (Sass::Callable) set_function(name, value) Sets a function in this Environment or one of its #parents.
- - (Sass::Callable) set_local_function(name, value) Sets a function in this Environment.
- - (Sass::Callable) set_local_mixin(name, value) Sets a mixin in this Environment.
- - (Script::Literal) set_local_var(name, value) Sets a variable in this Environment.
- - (Sass::Callable) set_mixin(name, value) Sets a mixin in this Environment or one of its #parents.
- - (Script::Literal) set_var(name, value) Sets a variable in this Environment or one of its #parents.
- - (Script::Literal) var(name) Gets a variable from this Environment or one of its #parents.
Constructor Details
- (Environment) initialize(parent = nil, options = nil)
A new instance of Environment
28 29 30 31 |
# File '/var/www/sass-pages/.sass/lib/sass/environment.rb', line 28
def initialize(parent = nil, options = nil)
@parent = parent
@options = options || (parent && parent.options) || {}
end
|
Instance Attribute Details
- (Environment?) caller
The environment of the caller of this environment’s mixin or function.
35 36 37 |
# File '/var/www/sass-pages/.sass/lib/sass/environment.rb', line 35
def caller
@caller || (@parent && @parent.caller)
end
|
- (Environment?) content
The content passed to this environmnet. This is naturally only set for mixin body environments with content passed in.
42 43 44 |
# File '/var/www/sass-pages/.sass/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 '/var/www/sass-pages/.sass/lib/sass/environment.rb', line 21
def options
@options
end
|
- (Environment) parent (readonly)
The enclosing environment, or nil if this is the global environment.
20 21 22 |
# File '/var/www/sass-pages/.sass/lib/sass/environment.rb', line 20
def parent
@parent
end
|
Instance Method Details
- (Sass::Callable) function(name)
Gets a function from this Environment or one of its #parents.
100 |
# File '/var/www/sass-pages/.sass/lib/sass/environment.rb', line 100
inherited_hash :function
|
- (Sass::Callable) mixin(name)
Gets a mixin from this Environment or one of its #parents.
97 |
# File '/var/www/sass-pages/.sass/lib/sass/environment.rb', line 97
inherited_hash :mixin
|
- (Sass::Callable) set_function(name, value)
Sets a function in this Environment or one of its #parents. If the function is already defined in some environment, that one is set; otherwise, a new one is created in this environment.
100 |
# File '/var/www/sass-pages/.sass/lib/sass/environment.rb', line 100
inherited_hash :function
|
- (Sass::Callable) set_local_function(name, value)
Sets a function in this Environment. Ignores any parent environments.
100 |
# File '/var/www/sass-pages/.sass/lib/sass/environment.rb', line 100
inherited_hash :function
|
- (Sass::Callable) set_local_mixin(name, value)
Sets a mixin in this Environment. Ignores any parent environments.
97 |
# File '/var/www/sass-pages/.sass/lib/sass/environment.rb', line 97
inherited_hash :mixin
|
- (Script::Literal) set_local_var(name, value)
Sets a variable in this Environment. Ignores any parent environments.
94 |
# File '/var/www/sass-pages/.sass/lib/sass/environment.rb', line 94
inherited_hash :var
|
- (Sass::Callable) set_mixin(name, value)
Sets a mixin in this Environment or one of its #parents. If the mixin is already defined in some environment, that one is set; otherwise, a new one is created in this environment.
97 |
# File '/var/www/sass-pages/.sass/lib/sass/environment.rb', line 97
inherited_hash :mixin
|
- (Script::Literal) set_var(name, value)
Sets a variable in this Environment or one of its #parents. If the variable is already defined in some environment, that one is set; otherwise, a new one is created in this environment.
94 |
# File '/var/www/sass-pages/.sass/lib/sass/environment.rb', line 94
inherited_hash :var
|
- (Script::Literal) var(name)
Gets a variable from this Environment or one of its #parents.
94 |
# File '/var/www/sass-pages/.sass/lib/sass/environment.rb', line 94
inherited_hash :var
|