Sha256: 3618516e596439cf7e295a07a03a9758a3b727c1c092be9cec7ced859073e249

Contents?: true

Size: 1.38 KB

Versions: 177

Compression:

Stored size: 1.38 KB

Contents

require 'sass/tree/node'

module Sass::Tree
  # A dynamic node representing a Sass `@while` loop.
  #
  # @see Sass::Tree
  class WhileNode < Node
    # @param expr [Script::Node] The parse tree for the continue expression
    def initialize(expr)
      @expr = expr
      super()
    end

    protected

    # @see Node#to_src
    def to_src(tabs, opts, fmt)
      "#{'  ' * tabs}@while #{@expr.to_sass(opts)}" + children_to_src(tabs, opts, fmt)
    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
    def _perform(environment)
      children = []
      new_environment = Sass::Environment.new(environment)
      while @expr.perform(environment).to_bool
        children += perform_children(new_environment)
      end
      children
    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
    def invalid_child?(child)
      super unless child.is_a?(ExtendNode)
    end
  end
end

Version data entries

177 entries across 176 versions & 5 rubygems

Version Path
radiant-1.0.0.rc1 vendor/plugins/haml/lib/sass/tree/while_node.rb
haml-3.1.0 vendor/sass/lib/sass/tree/while_node.rb
haml-3.1.0.alpha.147 vendor/sass/lib/sass/tree/while_node.rb
haml-3.1.0.alpha.145 vendor/sass/lib/sass/tree/while_node.rb
haml-3.1.0.alpha.144 vendor/sass/lib/sass/tree/while_node.rb
haml-3.1.0.alpha.141 vendor/sass/lib/sass/tree/while_node.rb
haml-3.1.0.alpha.37 vendor/sass/lib/sass/tree/while_node.rb
radiantcms-couchrest_model-0.1.3 vendor/plugins/haml/lib/sass/tree/while_node.rb
radiantcms-couchrest_model-0.1.2 vendor/plugins/haml/lib/sass/tree/while_node.rb
radiantcms-couchrest_model-0.1.1 vendor/plugins/haml/lib/sass/tree/while_node.rb
radiantcms-couchrest_model-0.1 vendor/plugins/haml/lib/sass/tree/while_node.rb
sass-3.1.0.alpha.47 lib/sass/tree/while_node.rb
sass-3.1.0.alpha.46 lib/sass/tree/while_node.rb
sass-3.1.0.alpha.45 lib/sass/tree/while_node.rb
sass-3.1.0.alpha.44 lib/sass/tree/while_node.rb
sass-3.1.0.alpha.43 lib/sass/tree/while_node.rb
haml-3.1.0.alpha.36 vendor/sass/lib/sass/tree/while_node.rb
sass-3.1.0.alpha.42 lib/sass/tree/while_node.rb
sass-3.1.0.alpha.41 lib/sass/tree/while_node.rb
sass-3.1.0.alpha.40 lib/sass/tree/while_node.rb