Class: Sass::Tree::WhileNode
Overview
A dynamic node representing a Sass @while loop.
Instance Method Summary
- - (Array<Tree::Node>) _perform(environment) protected Runs the child nodes until the continue expression becomes false.
- - (WhileNode) initialize(expr) constructor A new instance of WhileNode.
- - (Boolean, String) invalid_child?(child) protected Returns an error message if the given child node is invalid, and false otherwise.
- - 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, #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
- (WhileNode) initialize(expr)
A new instance of WhileNode
9 10 11 12 |
# File '/var/www/sass-pages/.haml/lib/sass/tree/while_node.rb', line 9
def initialize(expr)
@expr = expr
super()
end
|
Instance Method Details
- (Array<Tree::Node>) _perform(environment) (protected)
Runs the child nodes until the continue expression becomes false.
27 28 29 30 31 32 33 34 |
# File '/var/www/sass-pages/.haml/lib/sass/tree/while_node.rb', line 27
def _perform(environment)
children = []
new_environment = Sass::Environment.new(environment)
while @expr.perform(environment).to_bool
children += perform_children(new_environment)
end
children
end
|
- (Boolean, String) invalid_child?(child) (protected)
Returns an error message if the given child node is invalid, and false otherwise.
ExtendNodes are valid within WhileNodes.
44 45 46 |
# File '/var/www/sass-pages/.haml/lib/sass/tree/while_node.rb', line 44
def invalid_child?(child)
super unless child.is_a?(ExtendNode)
end
|
- to_src(tabs, opts, fmt) (protected)
17 18 19 |
# File '/var/www/sass-pages/.haml/lib/sass/tree/while_node.rb', line 17
def to_src(tabs, opts, fmt)
"#{' ' * tabs}@while #{@expr.to_sass(opts)}" + children_to_src(tabs, opts, fmt)
end
|