mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Parse self-closing tag
This commit is contained in:
parent
4e73bf2643
commit
9fb452934c
3 changed files with 16 additions and 4 deletions
|
@ -98,6 +98,8 @@ module Hamlit
|
||||||
if scanner.match?(/=/)
|
if scanner.match?(/=/)
|
||||||
ast << parse_script(scanner)
|
ast << parse_script(scanner)
|
||||||
return ast
|
return ast
|
||||||
|
elsif scanner.scan(/\//)
|
||||||
|
return ast
|
||||||
elsif scanner.rest.match(/[^ ]/)
|
elsif scanner.rest.match(/[^ ]/)
|
||||||
ast << parse_text(scanner)
|
ast << parse_text(scanner)
|
||||||
return ast
|
return ast
|
||||||
|
|
|
@ -175,5 +175,15 @@ describe Hamlit::Engine do
|
||||||
</span>
|
</span>
|
||||||
HTML
|
HTML
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'parses self-closing tag' do
|
||||||
|
assert_render(<<-HAML, <<-HTML, format: :xhtml)
|
||||||
|
%div/
|
||||||
|
%div
|
||||||
|
HAML
|
||||||
|
<div />
|
||||||
|
<div></div>
|
||||||
|
HTML
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,15 +6,15 @@ module HamlitSpecHelper
|
||||||
Hamlit::Parser.new.call(str)
|
Hamlit::Parser.new.call(str)
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_string(str)
|
def render_string(str, options = {})
|
||||||
eval Hamlit::Engine.new.call(str)
|
eval Hamlit::Engine.new(options).call(str)
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_render(haml, html)
|
def assert_render(haml, html, options = {})
|
||||||
haml = haml.unindent
|
haml = haml.unindent
|
||||||
html = html.unindent
|
html = html.unindent
|
||||||
|
|
||||||
expect(render_string(haml)).to eq(html)
|
expect(render_string(haml, options)).to eq(html)
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_parse(haml, &block)
|
def assert_parse(haml, &block)
|
||||||
|
|
Loading…
Add table
Reference in a new issue