lib/hamlit/compiler/attribute_compiler.rb in hamlit-2.1.1 vs lib/hamlit/compiler/attribute_compiler.rb in hamlit-2.1.2
- old
+ new
@@ -59,31 +59,31 @@
end
def compile_id!(temple, key, values)
build_code = attribute_builder(:id, values)
if values.all? { |type, exp| type == :static || StaticAnalyzer.static?(exp) }
- temple << [:html, :attr, key, [:static, eval(build_code)]]
+ temple << [:html, :attr, key, [:static, eval(build_code).to_s]]
else
temple << [:html, :attr, key, [:dynamic, build_code]]
end
end
def compile_class!(temple, key, values)
build_code = attribute_builder(:class, values)
if values.all? { |type, exp| type == :static || StaticAnalyzer.static?(exp) }
- temple << [:html, :attr, key, [:static, eval(build_code)]]
+ temple << [:html, :attr, key, [:static, eval(build_code).to_s]]
else
temple << [:html, :attr, key, [:dynamic, build_code]]
end
end
def compile_data!(temple, key, values)
args = [@escape_attrs.inspect, @quote.inspect, values.map { |v| literal_for(v) }]
build_code = "::Hamlit::AttributeBuilder.build_data(#{args.join(', ')})"
if values.all? { |type, exp| type == :static || StaticAnalyzer.static?(exp) }
- temple << [:static, eval(build_code)]
+ temple << [:static, eval(build_code).to_s]
else
temple << [:dynamic, build_code]
end
end
@@ -93,10 +93,10 @@
if StaticAnalyzer.static?(exp)
value = eval(exp)
case value
when true then temple << [:html, :attr, key, @format == :xhtml ? [:static, key] : [:multi]]
when false, nil
- else temple << [:html, :attr, key, [:escape, @escape_attrs, [:static, value]]]
+ else temple << [:html, :attr, key, [:escape, @escape_attrs, [:static, value.to_s]]]
end
else
var = @identity.generate
temple << [
:case, "(#{var} = (#{exp}))",