Class: Haml::Compiler::ScriptCompiler

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identity, options) ⇒ ScriptCompiler

Returns a new instance of ScriptCompiler.



15
16
17
18
# File 'lib/haml/compiler/script_compiler.rb', line 15

def initialize(identity, options)
  @identity = identity
  @disable_capture = options[:disable_capture]
end

Class Method Details

.find_and_preserve(input, tags = ::Haml::Preserver::DEFAULT_TAGS)



11
12
13
# File 'lib/haml/compiler/script_compiler.rb', line 11

def self.find_and_preserve(input, tags = ::Haml::Preserver::DEFAULT_TAGS)
  ::Haml::Preserver.find_and_preserve(input, tags) { |content| ::Haml::Helpers.preserve(content) }
end

Instance Method Details

#compile(node, &block)



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/haml/compiler/script_compiler.rb', line 20

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