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.



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

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



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

def compile(node)
  hashes = []
  return runtime_compile(node) if node.value[:object_ref] != :nil
  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