Sha256: d1b2ebf737b7d67b2705a4598b23a1c8ed4a55c139d236a287a9cf189fb5a1d0

Contents?: true

Size: 690 Bytes

Versions: 7

Compression:

Stored size: 690 Bytes

Contents

# frozen_string_literal: true
module Temple
  module Filters
    # @api public
    class CodeMerger < Filter
      def on_multi(*exps)
        result = [:multi]
        code = nil

        exps.each do |exp|
          if exp.first == :code
            if code
              code << '; ' unless code =~ /\n\Z/
              code << exp.last
            else
              code = exp.last.dup
              result << [:code, code]
            end
          elsif code && exp.first == :newline
            code << "\n"
          else
            result << compile(exp)
            code = nil
          end
        end

        result.size == 2 ? result[1] : result
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
brakeman-6.2.2 bundle/ruby/3.1.0/gems/temple-0.10.3/lib/temple/filters/code_merger.rb
brakeman-6.2.2.rc1 bundle/ruby/3.3.0/gems/temple-0.10.3/lib/temple/filters/code_merger.rb
brakeman-6.2.1 bundle/ruby/3.1.0/gems/temple-0.10.3/lib/temple/filters/code_merger.rb
brakeman-6.2.0 bundle/ruby/3.1.0/gems/temple-0.10.3/lib/temple/filters/code_merger.rb
temple-0.10.3 lib/temple/filters/code_merger.rb
temple-0.10.2 lib/temple/filters/code_merger.rb
temple-0.10.1 lib/temple/filters/code_merger.rb