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?(/=/)
|
||||
ast << parse_script(scanner)
|
||||
return ast
|
||||
elsif scanner.scan(/\//)
|
||||
return ast
|
||||
elsif scanner.rest.match(/[^ ]/)
|
||||
ast << parse_text(scanner)
|
||||
return ast
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue