1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00
haml--haml/lib/sass/tree/for_node.rb

27 lines
598 B
Ruby
Raw Normal View History

require 'sass/tree/node'
module Sass::Tree
class ForNode < Node
def initialize(var, from, to, exclusive, options)
@var = var
@from = from
@to = to
@exclusive = exclusive
super(options)
end
protected
def _perform(environment)
from = @from.perform(environment).to_i
to = @to.perform(environment).to_i
range = Range.new(from, to, @exclusive)
children = []
sub_env = environment.dup
range.each {|i| children += perform_children(sub_env.merge(@var => Sass::Script::Number.new(i)))}
children
end
end
end