Sha256: d9de079e8b8b3b559f76ea215f98df6005da6c2b17975da7d26134d9b4e3bded

Contents?: true

Size: 547 Bytes

Versions: 170

Compression:

Stored size: 547 Bytes

Contents

module Temple
  module Filters
    # Flattens nested multi expressions
    #
    # @api public
    class MultiFlattener < Filter
      def on_multi(*exps)
        # If the multi contains a single element, just return the element
        return compile(exps.first) if exps.size == 1
        result = [:multi]

        exps.each do |exp|
          exp = compile(exp)
          if exp.first == :multi
            result.concat(exp[1..-1])
          else
            result << exp
          end
        end

        result
      end
    end
  end
end

Version data entries

170 entries across 156 versions & 8 rubygems

Version Path
temple-0.6.0 lib/temple/filters/multi_flattener.rb
classiccms-0.6.9 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/multi_flattener.rb
classiccms-0.6.8 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/multi_flattener.rb
classiccms-0.6.7 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/multi_flattener.rb
classiccms-0.6.6 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/multi_flattener.rb
classiccms-0.6.5 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/multi_flattener.rb
classiccms-0.6.4 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/multi_flattener.rb
temple-0.5.5 lib/temple/filters/multi_flattener.rb
classiccms-0.6.3 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/multi_flattener.rb
classiccms-0.6.2 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/multi_flattener.rb
classiccms-0.6.1 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/multi_flattener.rb
classiccms-0.6.0 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/multi_flattener.rb
temple-0.5.4 lib/temple/filters/multi_flattener.rb
classiccms-0.5.17 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/multi_flattener.rb
classiccms-0.5.16 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/multi_flattener.rb
classiccms-0.5.15 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/multi_flattener.rb
classiccms-0.5.14 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/multi_flattener.rb
classiccms-0.5.13 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/multi_flattener.rb
temple-0.4.1 lib/temple/filters/multi_flattener.rb
classiccms-0.5.12 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/multi_flattener.rb