From 634bcad7d9e6232252f542831b99cf160f1b7bac Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 11 Oct 2015 11:58:14 +0900 Subject: [PATCH] Compile attributes --- lib/hamlit/compiler.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/hamlit/compiler.rb b/lib/hamlit/compiler.rb index 63945c36..907bd6e5 100644 --- a/lib/hamlit/compiler.rb +++ b/lib/hamlit/compiler.rb @@ -9,7 +9,7 @@ module Hamlit when :root compile_children(node) when :tag - [:html, :tag, node.value[:name], [:html, :attrs], [:multi]] + compile_tag(node) else [:static, "\n"] end @@ -22,5 +22,13 @@ module Hamlit temple = node.children.map { |n| compile(n) } [:multi, *temple] 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