Sha256: b19a42c6a90e33ae9867fca840ac1c6e6082d58f9d602973847ff1c1dc67f2ab

Contents?: true

Size: 792 Bytes

Versions: 118

Compression:

Stored size: 792 Bytes

Contents

module Temple
  module Filters
    # Merges several statics into a single static.  Example:
    #
    #   [:multi,
    #     [:static, "Hello "],
    #     [:static, "World!"]]
    #
    # Compiles to:
    #
    #   [: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.size == 2 ? result[1] : result
      end
    end
  end
end

Version data entries

118 entries across 104 versions & 7 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/temple-0.8.2/lib/temple/filters/static_merger.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/temple-0.8.2/lib/temple/filters/static_merger.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/temple-0.8.2/lib/temple/filters/static_merger.rb
brakeman-6.1.2 bundle/ruby/3.3.0/gems/temple-0.8.2/lib/temple/filters/static_merger.rb
brakeman-6.1.1 bundle/ruby/3.0.0/gems/temple-0.8.2/lib/temple/filters/static_merger.rb
brakeman-6.1.0 bundle/ruby/3.1.0/gems/temple-0.8.2/lib/temple/filters/static_merger.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/static_merger.rb
brakeman-6.0.1 bundle/ruby/3.1.0/gems/temple-0.8.2/lib/temple/filters/static_merger.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/static_merger.rb
brakeman-6.0.0 bundle/ruby/3.0.0/gems/temple-0.8.2/lib/temple/filters/static_merger.rb
brakeman-5.4.1 bundle/ruby/3.1.0/gems/temple-0.8.2/lib/temple/filters/static_merger.rb
temple-0.10.0 lib/temple/filters/static_merger.rb
brakeman-5.4.0 bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/static_merger.rb
temple-0.9.1 lib/temple/filters/static_merger.rb
temple-0.9.0 lib/temple/filters/static_merger.rb
brakeman-5.3.1 bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/static_merger.rb
brakeman-5.3.0 bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/static_merger.rb
brakeman-5.2.3 bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/static_merger.rb
brakeman-5.2.2 bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/static_merger.rb
brakeman-5.2.1 bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/static_merger.rb