Sha256: 8afca8c490aa1b011d3c95a71d0c34c78b3a4eed002cbd66a20c7e8de1077642

Contents?: true

Size: 541 Bytes

Versions: 6

Compression:

Stored size: 541 Bytes

Contents

module Hamlit
  module Block
    # Suppress block's internal rendering result and pass it to [:capture, ...].
    class ScriptCompiler < ::Hamlit::Compiler::ScriptCompiler
      def compile_script_assign(var, node, &block)
        if node.children.empty?
          super
        else
          [:multi,
           [:block, "#{var} = #{node.value[:text]}",
            [:multi,
             [:newline],
             [:capture, @identity.generate, yield(node)],
            ],
           ],
          ]
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hamlit-block-0.8.0 lib/hamlit/block/script_compiler.rb
hamlit-block-0.7.1 lib/hamlit/block/script_compiler.rb
hamlit-block-0.7.0 lib/hamlit/block/script_compiler.rb
hamlit-block-0.6.0 lib/hamlit/block/script_compiler.rb
hamlit-block-0.5.0 lib/hamlit/block/script_compiler.rb
hamlit-block-0.4.0 lib/hamlit/block/script_compiler.rb