Class: Hamlit::Block::ScriptCompiler

Inherits:
Compiler::ScriptCompiler
  • Object
show all
Defined in:
lib/hamlit/block/script_compiler.rb

Overview

Suppress block’s internal rendering result and pass it to [:capture, …].

Instance Method Summary collapse

Instance Method Details

#compile_script_assign(var, node, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/hamlit/block/script_compiler.rb', line 5

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