0
@@ -431,14 +431,14 @@ END
0
def parse_static_hash(text)
0
- return {} unless text
&& inner = text.scan(/^\{(.*)\}$/)[0]0
-
inner[0].split(',').each do |attrib|
0
+
text.split(',').each do |attrib|
0
key, value, more = attrib.split('=>')
0
# Make sure the key and value and only the key and value exist
0
- # Otherwise, it's too complicated
and we'll defer it to the actual Ruby parser
0
+ # Otherwise, it's too complicated
or dynamic and we'll defer it to the actual Ruby parser
0
key = parse_literal_value key
0
value = parse_literal_value value
0
return nil if more || key.nil? || value.nil?
0
raise SyntaxError.new("Invalid tag: \"#{line}\"") unless match = line.scan(TAG_REGEX)[0]
0
tag_name, attributes, attributes_hash, object_ref, action, value = match
0
value = value.to_s.strip
0
+ attributes_hash = attributes_hash[1...-1] if attributes_hash
0
raise SyntaxError.new("Illegal element: classes and ids must have values.") if attributes =~ /[\.#](\.|#|\z)/
0
object_ref = "nil" if object_ref.nil? || @options[:suppress_eval]
0
static_attributes = parse_static_hash(attributes_hash) # Try pre-compiling a static attributes hash
0
- attributes_hash =
"{nil}" if attributes_hash.nil? || static_attributes || @options[:suppress_eval]
0
+ attributes_hash =
nil if static_attributes || @options[:suppress_eval]
0
attributes = parse_class_and_id(attributes)
0
Buffer.merge_attrs(attributes, static_attributes) if static_attributes
0
atomic = true if !@block_opened && value.empty? && @options[:autoclose].include?(tag_name)
0
- if object_ref == "nil" && attributes_hash
== "{nil}" && !flattened && (parse || Buffer.one_liner?(value))
0
+ if object_ref == "nil" && attributes_hash
.nil? && !flattened && (parse || Buffer.one_liner?(value))
0
# This means that we can render the tag directly to text and not process it in the buffer
0
tag_closed = !value.empty? && Buffer.one_liner?(value) && !parse
0
content = value.empty? || parse ? 'nil' : value.dump
0
- push_silent "_hamlout.open_tag(#{tag_name.inspect}, #{atomic.inspect}, #{(!value.empty?).inspect}, #{attributes.inspect}, #{object_ref}, #{content}, #{attributes_hash[1...-1]})"
0
+ attributes_hash = ', ' + attributes_hash if attributes_hash
0
+ push_silent "_hamlout.open_tag(#{tag_name.inspect}, #{atomic.inspect}, #{(!value.empty?).inspect}, #{attributes.inspect}, #{object_ref}, #{content}#{attributes_hash})"
Comments
No one has commented yet.