Class: Haml::AttributeCompiler
- Inherits:
-
Object
- Object
- Haml::AttributeCompiler
- Defined in:
- lib/haml/attribute_compiler.rb
Instance Method Summary collapse
-
#compile(node)
-
#initialize(identity, options) ⇒ AttributeCompiler
constructor
A new instance of AttributeCompiler.
Constructor Details
#initialize(identity, options) ⇒ AttributeCompiler
Returns a new instance of AttributeCompiler.
18 19 20 21 22 23 |
# File 'lib/haml/attribute_compiler.rb', line 18
def initialize(identity, options)
@identity = identity
@quote = options[:attr_quote]
@format = options[:format]
@escape_attrs = options[:escape_attrs]
end
|
Instance Method Details
#compile(node)
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/haml/attribute_compiler.rb', line 25
def compile(node)
hashes = []
return runtime_compile(node) if node.value[:object_ref] != :nil
dynamic_attributes = node.value[:dynamic_attributes]
[dynamic_attributes.new, dynamic_attributes.old].compact.each do |attribute_str|
hash = AttributeParser.parse(attribute_str)
return runtime_compile(node) if hash.nil? || hash.any? { |_key, value| value.empty? }
hashes << hash
end
temple = static_compile(node.value[:attributes], hashes)
restore_newlines!(temple, dynamic_attributes)
temple
end
|