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
classiccms-0.3.2 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/multi_flattener.rb
classiccms-0.3.1 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/multi_flattener.rb
classiccms-0.3.0 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/multi_flattener.rb
classiccms-0.2.4.pre vendor/bundle/gems/temple-0.4.0/lib/temple/filters/multi_flattener.rb
temple-0.4.0 lib/temple/filters/multi_flattener.rb
temple-0.3.5 lib/temple/filters/multi_flattener.rb
temple-0.3.4 lib/temple/filters/multi_flattener.rb
temple-0.3.2 lib/temple/filters/multi_flattener.rb
temple-0.3.1 lib/temple/filters/multi_flattener.rb
temple-0.3.0 lib/temple/filters/multi_flattener.rb