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

Compile attributes

This commit is contained in:
Takashi Kokubun 2015-10-11 11:58:14 +09:00
parent b235f9a9e7
commit 634bcad7d9

View file

@ -9,7 +9,7 @@ module Hamlit
when :root when :root
compile_children(node) compile_children(node)
when :tag when :tag
[:html, :tag, node.value[:name], [:html, :attrs], [:multi]] compile_tag(node)
else else
[:static, "\n"] [:static, "\n"]
end end
@ -22,5 +22,13 @@ module Hamlit
temple = node.children.map { |n| compile(n) } temple = node.children.map { |n| compile(n) }
[:multi, *temple] [:multi, *temple]
end end
def compile_tag(node)
attrs = [:html, :attrs]
node.value[:attributes].each do |name, value|
attrs << [:html, :attr, name, [:static, value]]
end
[:html, :tag, node.value[:name], attrs, [:multi]]
end
end end
end end