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

Compile inline plane properly

This commit is contained in:
Takashi Kokubun 2015-10-11 23:13:28 +09:00
parent 15ae22e3b2
commit 1cc916909a
2 changed files with 34 additions and 30 deletions

View file

@ -1,3 +1,5 @@
require 'haml/util'
module Hamlit
class TagCompiler
def initialize(options = {})
@ -31,8 +33,10 @@ module Hamlit
yield(node)
when node.value[:value].nil? && self_closing?(node)
nil
else
when Haml::Util.contains_interpolation?(node.value[:value])
[:dynamic, node.value[:value]]
else
[:static, node.value[:value]]
end
end

View file

@ -118,17 +118,17 @@ basic Haml tags and CSS:
an implicit div with a CSS class:
haml: ".class1"
html: "<div class='class1'></div>"
# multiple simple Haml tags:
# haml: |-
# %div
# %div
# %p
# html: |-
# <div>
# <div>
# <p></p>
# </div>
# </div>
multiple simple Haml tags:
haml: |-
%div
%div
%p
html: |-
<div>
<div>
<p></p>
</div>
</div>
tags with unusual HTML characters:
a tag with colons:
haml: "%ns:tag"
@ -155,24 +155,24 @@ tags with unusual CSS identifiers:
a class with dashes:
haml: ".--"
html: "<div class='--'></div>"
# tags with inline content:
# Inline content simple tag:
# haml: "%p hello"
# html: "<p>hello</p>"
# Inline content tag with CSS:
# haml: "%p.class1 hello"
# html: "<p class='class1'>hello</p>"
# Inline content multiple simple tags:
# haml: |-
# %div
# %div
# %p text
# html: |-
# <div>
# <div>
# <p>text</p>
# </div>
# </div>
tags with inline content:
Inline content simple tag:
haml: "%p hello"
html: "<p>hello</p>"
Inline content tag with CSS:
haml: "%p.class1 hello"
html: "<p class='class1'>hello</p>"
Inline content multiple simple tags:
haml: |-
%div
%div
%p text
html: |-
<div>
<div>
<p>text</p>
</div>
</div>
tags with nested content:
Nested content simple tag:
haml: |-