Class: FastHaml::Html
- Inherits:
-
Temple::HTML::Fast
- Object
- Temple::HTML::Fast
- FastHaml::Html
- Defined in:
- lib/fast_haml/html.rb
Instance Method Summary collapse
- #on_haml_attr(name, value) ⇒ Object
- #on_haml_attrs(code) ⇒ Object
- #on_haml_doctype(type) ⇒ Object
- #on_haml_preserve(sym) ⇒ Object
- #on_haml_tag(name, self_closing, attrs, content = nil) ⇒ Object
Instance Method Details
#on_haml_attr(name, value) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/fast_haml/html.rb', line 19 def on_haml_attr(name, value) if empty_exp?(value) if @format == :html [:static, " #{name}"] else [:static, " #{name}=#{[:attr_quote]}#{name}#{[:attr_quote]}"] end elsif value[0] == :dvalue sym = unique_name [:multi, [:code, "#{sym} = (#{value[1]})"], [:case, sym, ['true', [:static, " #{name}"]], ['false, nil', [:multi]], [:else, [:multi, [:static, " #{name}=#{[:attr_quote]}"], [:escape, true, [:dynamic, sym]], [:static, [:attr_quote]], ]], ], ] else [:multi, [:static, " #{name}=#{[:attr_quote]}"], compile(value), [:static, [:attr_quote]]] end end |
#on_haml_attrs(code) ⇒ Object
15 16 17 |
# File 'lib/fast_haml/html.rb', line 15 def on_haml_attrs(code) [:dynamic, "::FastHaml::AttributeBuilder.build(#{[:attr_quote].inspect}, #{code})"] end |
#on_haml_doctype(type) ⇒ Object
48 49 50 51 52 |
# File 'lib/fast_haml/html.rb', line 48 def on_haml_doctype(type) compile([:html, :doctype, type]) rescue Temple::FilterError [:multi] end |
#on_haml_preserve(sym) ⇒ Object
54 55 56 |
# File 'lib/fast_haml/html.rb', line 54 def on_haml_preserve(sym) [:dynamic, "::FastHaml::Compiler.find_and_preserve(#{sym}.to_s)"] end |
#on_haml_tag(name, self_closing, attrs, content = nil) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/fast_haml/html.rb', line 5 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 end |