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:
parent
715dff53a7
commit
81be1a8b18
2 changed files with 10 additions and 8 deletions
|
@ -25,7 +25,11 @@ module Hamlit
|
|||
tokens = Ripper.lex(str)
|
||||
key = read_key!(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
|
||||
break unless token
|
||||
|
@ -40,15 +44,14 @@ module Hamlit
|
|||
def read_key!(tokens)
|
||||
skip_tokens!(tokens, :on_sp)
|
||||
(row, col), type, key = tokens.shift
|
||||
|
||||
skip_tokens!(tokens, :on_sp)
|
||||
(row, col), type, str = tokens.shift
|
||||
raise SyntaxError if str != '='
|
||||
|
||||
key
|
||||
end
|
||||
|
||||
def read_value!(tokens)
|
||||
skip_tokens!(tokens, :on_sp)
|
||||
(row, col), type, str = tokens.shift
|
||||
return nil if str != '='
|
||||
|
||||
skip_tokens!(tokens, :on_sp)
|
||||
return if tokens.empty?
|
||||
|
||||
|
|
|
@ -476,8 +476,7 @@ describe "haml" do
|
|||
assert_ugly(haml, locals, options)
|
||||
end
|
||||
|
||||
# FIXME: currently this is not considered
|
||||
pending "HTML-style tag with an atomic attribute" do
|
||||
specify "HTML-style tag with an atomic attribute" do
|
||||
haml = %q{%a(flag)}
|
||||
html = %q{<a flag></a>}
|
||||
locals = {}
|
||||
|
|
Loading…
Add table
Reference in a new issue