Class Sass::Tree::ForNode
In: lib/sass/tree/for_node.rb
Parent: Node
Haml::Util Engine Color SyntaxError UnitConversionError StandardError Node Operation Literal UnaryOperation Funcall Variable Number String Bool EvaluationContext Node\n[lib/sass/css.rb\nlib/sass/tree/node.rb] DebugNode IfNode CommentNode ForNode MixinNode VariableNode ImportNode WhileNode MixinDefNode Repl CSS Environment Lexer Parser PropNode\n[lib/sass/css.rb\nlib/sass/tree/prop_node.rb] DirectiveNode\n[lib/sass/css.rb\nlib/sass/tree/directive_node.rb] RuleNode\n[lib/sass/css.rb\nlib/sass/tree/rule_node.rb] Rack lib/sass/repl.rb lib/sass/css.rb lib/sass/environment.rb lib/sass/error.rb lib/sass/engine.rb lib/sass/script/lexer.rb lib/sass/script/color.rb lib/sass/script/string.rb lib/sass/script/unary_operation.rb lib/sass/script/variable.rb lib/sass/script/funcall.rb lib/sass/script/operation.rb lib/sass/script/bool.rb lib/sass/script/parser.rb lib/sass/script/literal.rb lib/sass/script/node.rb lib/sass/script/number.rb lib/sass/script/functions.rb Functions Script Files lib/sass/tree/while_node.rb lib/sass/tree/if_node.rb lib/sass/tree/mixin_def_node.rb lib/sass/tree/debug_node.rb lib/sass/tree/for_node.rb lib/sass/tree/import_node.rb lib/sass/tree/prop_node.rb lib/sass/tree/node.rb lib/sass/tree/comment_node.rb lib/sass/tree/mixin_node.rb lib/sass/tree/directive_node.rb lib/sass/tree/rule_node.rb lib/sass/tree/variable_node.rb Tree lib/sass/plugin/rack.rb Plugin Sass dot/m_54_0.png

A dynamic node representing a Sass `@for` loop.

@see Sass::Tree

Methods

_perform   new  

Public Class methods

@param var [String] The name of the loop variable @param from [Script::Node] The parse tree for the initial expression @param to [Script::Node] The parse tree for the final expression @param exclusive [Boolean] Whether to include `to` in the loop

  or stop just before

[Source]

    # File lib/sass/tree/for_node.rb, line 13
13:     def initialize(var, from, to, exclusive)
14:       @var = var
15:       @from = from
16:       @to = to
17:       @exclusive = exclusive
18:       super()
19:     end

Protected Instance methods

Runs the child nodes once for each time through the loop, varying the variable each time.

@param environment [Sass::Environment] The lexical environment containing

  variable and mixin values

@return [Array<Tree::Node>] The resulting static nodes @see Sass::Tree

[Source]

    # File lib/sass/tree/for_node.rb, line 30
30:     def _perform(environment)
31:       from = @from.perform(environment)
32:       to = @to.perform(environment)
33:       from.assert_int!
34:       to.assert_int!
35: 
36:       to = to.coerce(from.numerator_units, from.denominator_units)
37:       range = Range.new(from.to_i, to.to_i, @exclusive)
38: 
39:       children = []
40:       environment = Sass::Environment.new(environment)
41:       range.each do |i|
42:         environment.set_local_var(@var, Sass::Script::Number.new(i, from.numerator_units, from.denominator_units))
43:         children += perform_children(environment)
44:       end
45:       children
46:     end

[Validate]