| Class | Sass::Tree::WhileNode |
| In: |
lib/sass/tree/while_node.rb
|
| Parent: | Node |
A dynamic node representing a Sass `@while` loop.
@see Sass::Tree
@param expr [Script::Node] The parse tree for the continue expression
# File lib/sass/tree/while_node.rb, line 9
9: def initialize(expr)
10: @expr = expr
11: super()
12: end
Runs the child nodes until the continue expression becomes false.
@param environment [Sass::Environment] The lexical environment containing
variable and mixin values
@return [Array<Tree::Node>] The resulting static nodes @see Sass::Tree
# File lib/sass/tree/while_node.rb, line 27
27: def _perform(environment)
28: children = []
29: new_environment = Sass::Environment.new(environment)
30: while @expr.perform(environment).to_bool
31: children += perform_children(new_environment)
32: end
33: children
34: end
Returns an error message if the given child node is invalid, and false otherwise.
{ExtendNode}s are valid within {WhileNode}s.
@param child [Tree::Node] A potential child node. @return [Boolean, String] Whether or not the child node is valid,
as well as the error message to display if it is invalid
# File lib/sass/tree/while_node.rb, line 44
44: def invalid_child?(child)
45: super unless child.is_a?(ExtendNode)
46: end
@see Node#to_src
# File lib/sass/tree/while_node.rb, line 17
17: def to_src(tabs, opts, fmt)
18: "#{' ' * tabs}@while #{@expr.to_sass(opts)}" + children_to_src(tabs, opts, fmt)
19: end