Class: Sass::Environment

Inherits:
Object
  • Object
show all
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

Instance Method Summary

Constructor Details

- (Environment) initialize(parent = nil, options = nil)

A new instance of Environment

Parameters:



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.

Returns:



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.

Returns:



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.

Returns:



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.

Parameters:

  • (String) name — The name of the function

Returns:



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.

Parameters:

  • (String) name — The name of the mixin

Returns:



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.

Parameters:

  • (String) name — The name of the function
  • (Sass::Callable) value — The value of the function

Returns:



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.

Parameters:

  • (String) name — The name of the function
  • (Sass::Callable) value — The value of the function

Returns:



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.

Parameters:

  • (String) name — The name of the mixin
  • (Sass::Callable) value — The value of the mixin

Returns:



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.

Parameters:

  • (String) name — The name of the variable
  • (Script::Literal) value — The value of the variable

Returns:



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.

Parameters:

  • (String) name — The name of the mixin
  • (Sass::Callable) value — The value of the mixin

Returns:



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.

Parameters:

  • (String) name — The name of the variable
  • (Script::Literal) value — The value of the variable

Returns:



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.

Parameters:

  • (String) name — The name of the variable

Returns:



94
# File '/var/www/sass-pages/.sass/lib/sass/environment.rb', line 94

inherited_hash :var