lib/faml/html.rb in faml-0.3.2 vs lib/faml/html.rb in faml-0.3.3

- old
+ new

@@ -1,20 +1,20 @@ require 'faml/attribute_builder' module Faml class Html < Temple::HTML::Fast # Override temple's default - self.options[:format] = :html - self.options[:attr_quote] = "'" + options[:format] = :html + options[:attr_quote] = "'" def on_haml_tag(name, self_closing, attrs, content = nil) name = name.to_s closed = self_closing && (!content || empty_exp?(content)) result = [:multi, [:static, "<#{name}"], compile(attrs)] result << [:static, (closed && @format != :html ? ' /' : '') + '>'] result << compile(content) if content - result << [:static, "</#{name}>"] if !closed + result << [:static, "</#{name}>"] unless closed result end def on_haml_attrs(code) [:dynamic, "::Faml::AttributeBuilder.build(#{options[:attr_quote].inspect}, #{options[:format] == :html}, #{code})"] @@ -24,25 +24,25 @@ if empty_exp?(value) true_attribute(name) elsif value[0] == :dvalue sym = unique_name [:multi, - [:code, "#{sym} = (#{value[1]})"], - [:case, sym, - ['true', true_attribute(name)], - ['false, nil', [:multi]], - [:else, [:multi, - [:static, " #{name}=#{options[:attr_quote]}"], - [:escape, true, [:dynamic, sym]], - [:static, options[:attr_quote]], - ]], - ], + [:code, "#{sym} = (#{value[1]})"], + [:case, sym, + ['true', true_attribute(name)], + ['false, nil', [:multi]], + [:else, [:multi, + [:static, " #{name}=#{options[:attr_quote]}"], + [:escape, true, [:dynamic, sym]], + [:static, options[:attr_quote]], + ]], + ], ] else [:multi, - [:static, " #{name}=#{options[:attr_quote]}"], - compile(value), - [:static, options[:attr_quote]]] + [:static, " #{name}=#{options[:attr_quote]}"], + compile(value), + [:static, options[:attr_quote]]] end end def on_haml_doctype(type) compile([:html, :doctype, type])