Sha256: afc8a1d07d277300e0c2f822493f8ef40bd1c540901f668faf41129cb4ebd065

Contents?: true

Size: 907 Bytes

Versions: 7

Compression:

Stored size: 907 Bytes

Contents

module Skim
  class Compiler < Slim::Compiler
    def on_slim_control(code, content)
      [:multi,
        [:code, code],
        [:indent, compile(content)]]
    end

    def on_slim_attr(name, escape, code)
      value = case code
      when 'true'
        escape = false
        [:static, name]
      when 'false', 'null'
        escape = false
        [:multi]
      else
        tmp = unique_name
        [:multi,
         [:code, "#{tmp} = #{code}"],
         [:case, tmp,
          ['true', [:static, name]],
          ['false, null', [:multi]],
          [:else,
           [:dynamic,
            #if delimiter = options[:attr_delimiter][name]
            #  "#{tmp}.respond_to?(:join) ? #{tmp}.flatten.compact.join(#{delimiter.inspect}) : #{tmp}"
            #else
              tmp
            #end
           ]]]]
      end
      [:html, :attr, name, [:escape, escape, value]]
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
skim-0.8.6 lib/skim/compiler.rb
skim-0.8.5 lib/skim/compiler.rb
skim-0.8.4 lib/skim/compiler.rb
skim-0.8.3 lib/skim/compiler.rb
skim-0.8.2 lib/skim/compiler.rb
skim-0.8.1 lib/skim/compiler.rb
skim-0.8.0 lib/skim/compiler.rb