Sha256: 3f35ea5c0b4b42c32a5148330a0c435edd188fd8fbbb48f8ab6256485c13a5a3

Contents?: true

Size: 781 Bytes

Versions: 52

Compression:

Stored size: 781 Bytes

Contents

module Temple
  module Filters
    # Merges several statics into a single static.  Example:
    #
    #   [:multi,
    #     [:static, "Hello "],
    #     [:static, "World!"]]
    #
    # Compiles to:
    #
    #   [:multi,
    #     [:static, "Hello World!"]]
    #
    # @api public
    class StaticMerger < Filter
      def on_multi(*exps)
        result = [:multi]
        text = nil

        exps.each do |exp|
          if exp.first == :static
            if text
              text << exp.last
            else
              text = exp.last.dup
              result << [:static, text]
            end
          else
            result << compile(exp)
            text = nil unless exp.first == :newline
          end
        end

        result
      end
    end
  end
end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/static_merger.rb
classiccms-0.7.4 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/static_merger.rb
classiccms-0.7.3 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/static_merger.rb
classiccms-0.7.2 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/static_merger.rb
classiccms-0.7.1 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/static_merger.rb
classiccms-0.7.0 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/static_merger.rb
classiccms-0.6.9 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/static_merger.rb
classiccms-0.6.8 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/static_merger.rb
classiccms-0.6.7 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/static_merger.rb
classiccms-0.6.6 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/static_merger.rb
classiccms-0.6.5 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/static_merger.rb
classiccms-0.6.4 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/static_merger.rb
classiccms-0.6.3 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/static_merger.rb
classiccms-0.6.2 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/static_merger.rb
classiccms-0.6.1 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/static_merger.rb
classiccms-0.6.0 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/static_merger.rb
classiccms-0.5.17 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/static_merger.rb
classiccms-0.5.16 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/static_merger.rb
classiccms-0.5.15 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/static_merger.rb
classiccms-0.5.14 vendor/bundle/gems/temple-0.4.0/lib/temple/filters/static_merger.rb