Class: Hamlit::AttributeCompiler

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

Instance Method Summary collapse

Constructor Details

#initialize(identity, options) ⇒ AttributeCompiler

Returns a new instance of AttributeCompiler.



8
9
10
11
12
13
# File 'lib/hamlit/attribute_compiler.rb', line 8

def initialize(identity, options)
  @identity = identity
  @quote  = options[:attr_quote]
  @format = options[:format]
  @escape_attrs = options[:escape_attrs]
end

Instance Method Details

#compile(node) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/hamlit/attribute_compiler.rb', line 15

def compile(node)
  hashes = []
  if node.value[:object_ref] != :nil || !Ripper.respond_to?(:lex) # No Ripper.lex in truffleruby
    return runtime_compile(node)
  end
  node.value[:attributes_hashes].each do |attribute_str|
    hash = AttributeParser.parse(attribute_str)
    return runtime_compile(node) unless hash
    hashes << hash
  end
  static_compile(node.value[:attributes], hashes)
end