From ec2aecb4bd848c4cd31946d6de4315368ad71e10 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sat, 14 Nov 2015 02:58:39 +0900 Subject: [PATCH] Compile static common attributes statically --- lib/hamlit/compiler/attribute_compiler.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/hamlit/compiler/attribute_compiler.rb b/lib/hamlit/compiler/attribute_compiler.rb index aaf200f0..403a6882 100644 --- a/lib/hamlit/compiler/attribute_compiler.rb +++ b/lib/hamlit/compiler/attribute_compiler.rb @@ -128,11 +128,16 @@ module Hamlit end def compile_common!(temple, key, static_value, dynamic_values) - value = build_attr(:static, key, static_value) if static_value + type, value = :static, static_value if static_value dynamic_values.each do |dynamic_value| - value = build_attr(:dynamic, key, dynamic_value) + type, value = :dynamic, dynamic_value end - temple << value + + if type == :dynamic && StaticAnalyzer.static?(value) + type, value = :static, eval("(#{value}).to_s") + end + + temple << build_attr(type, key, value) end def build_attr(type, key, value)