Class: Hamlit::Compiler::ScriptCompiler

Inherits:
Object
  • Object
show all
Defined in:
lib/hamlit/compiler/script_compiler.rb

Instance Method Summary collapse

Constructor Details

#initialize(identity) ⇒ ScriptCompiler

Returns a new instance of ScriptCompiler.



8
9
10
# File 'lib/hamlit/compiler/script_compiler.rb', line 8

def initialize(identity)
  @identity = identity
end

Instance Method Details

#compile(node, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/hamlit/compiler/script_compiler.rb', line 12

def compile(node, &block)
  no_children = node.children.empty?
  case
  when no_children && node.value[:escape_interpolation]
    compile_interpolated_plain(node)
  when no_children && RubyExpression.string_literal?(node.value[:text])
    delegate_optimization(node)
  when no_children && Temple::StaticAnalyzer.static?(node.value[:text])
    static_compile(node)
  else
    dynamic_compile(node, &block)
  end
end