1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Consider an atomic attribute in new style attributes

This commit is contained in:
Takashi Kokubun 2015-03-29 10:33:54 +09:00
parent 715dff53a7
commit 81be1a8b18
2 changed files with 10 additions and 8 deletions

View file

@ -25,7 +25,11 @@ module Hamlit
tokens = Ripper.lex(str) tokens = Ripper.lex(str)
key = read_key!(tokens) key = read_key!(tokens)
val = read_value!(tokens) val = read_value!(tokens)
attributes[key] = val if key && val if key && val
attributes[key] = val
elsif key
attributes[key] = 'true'
end
token = tokens.first token = tokens.first
break unless token break unless token
@ -40,15 +44,14 @@ module Hamlit
def read_key!(tokens) def read_key!(tokens)
skip_tokens!(tokens, :on_sp) skip_tokens!(tokens, :on_sp)
(row, col), type, key = tokens.shift (row, col), type, key = tokens.shift
skip_tokens!(tokens, :on_sp)
(row, col), type, str = tokens.shift
raise SyntaxError if str != '='
key key
end end
def read_value!(tokens) def read_value!(tokens)
skip_tokens!(tokens, :on_sp)
(row, col), type, str = tokens.shift
return nil if str != '='
skip_tokens!(tokens, :on_sp) skip_tokens!(tokens, :on_sp)
return if tokens.empty? return if tokens.empty?

View file

@ -476,8 +476,7 @@ describe "haml" do
assert_ugly(haml, locals, options) assert_ugly(haml, locals, options)
end end
# FIXME: currently this is not considered specify "HTML-style tag with an atomic attribute" do
pending "HTML-style tag with an atomic attribute" do
haml = %q{%a(flag)} haml = %q{%a(flag)}
html = %q{<a flag></a>} html = %q{<a flag></a>}
locals = {} locals = {}