Class: Sass::Tree::VariableNode
Overview
A dynamic node representing a variable definition.
Instance Method Summary
- - _perform(environment) protected Loads the new variable value into the environment.
- - (VariableNode) initialize(name, expr, guarded) constructor A new instance of VariableNode.
- - to_src(tabs, opts, fmt) protected
Methods inherited from Node
#<<, #==, #_cssize, #_to_s, #balance, #check_child!, #children_to_src, #cssize, #cssize!, #dasherize, #do_extend, #each, #invalid_child?, #invisible?, #perform, #perform!, #perform_children, #run_interp, #selector_to_sass, #selector_to_scss, #selector_to_src, #semi, #style, #to_s, #to_sass, #to_scss
Constructor Details
- (VariableNode) initialize(name, expr, guarded)
A new instance of VariableNode
10 11 12 13 14 15 |
# File '/var/www/haml-pages/.haml/lib/sass/tree/variable_node.rb', line 10
def initialize(name, expr, guarded)
@name = name
@expr = expr
@guarded = guarded
super()
end
|
Instance Method Details
- _perform(environment) (protected)
Loads the new variable value into the environment.
28 29 30 31 32 33 34 35 36 |
# File '/var/www/haml-pages/.haml/lib/sass/tree/variable_node.rb', line 28
def _perform(environment)
return [] if @guarded && !environment.var(@name).nil?
val = @expr.perform(environment)
if @expr.context == :equals && val.is_a?(Sass::Script::String)
val = Sass::Script::String.new(val.value)
end
environment.set_var(@name, val)
[]
end
|
- to_src(tabs, opts, fmt) (protected)
20 21 22 |
# File '/var/www/haml-pages/.haml/lib/sass/tree/variable_node.rb', line 20
def to_src(tabs, opts, fmt)
"#{' ' * tabs}$#{dasherize(@name, opts)}: #{@expr.to_sass(opts)}#{' !default' if @guarded}#{semi fmt}\n"
end
|