1
0
Fork 0
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:
Takashi Kokubun 2015-03-27 13:26:19 +09:00
parent 4e73bf2643
commit 9fb452934c
3 changed files with 16 additions and 4 deletions

View file

@ -98,6 +98,8 @@ module Hamlit
if scanner.match?(/=/)
ast << parse_script(scanner)
return ast
elsif scanner.scan(/\//)
return ast
elsif scanner.rest.match(/[^ ]/)
ast << parse_text(scanner)
return ast

View file

@ -175,5 +175,15 @@ describe Hamlit::Engine do
</span>
HTML
end
it 'parses self-closing tag' do
assert_render(<<-HAML, <<-HTML, format: :xhtml)
%div/
%div
HAML
<div />
<div></div>
HTML
end
end
end

View file

@ -6,15 +6,15 @@ module HamlitSpecHelper
Hamlit::Parser.new.call(str)
end
def render_string(str)
eval Hamlit::Engine.new.call(str)
def render_string(str, options = {})
eval Hamlit::Engine.new(options).call(str)
end
def assert_render(haml, html)
def assert_render(haml, html, options = {})
haml = haml.unindent
html = html.unindent
expect(render_string(haml)).to eq(html)
expect(render_string(haml, options)).to eq(html)
end
def assert_parse(haml, &block)