Method: Slim::CodeAttributes#on_html_attr
- Defined in:
- lib/slim/code_attributes.rb
#on_html_attr(name, value) ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Handle attribute expression [:html, :attr, name, value]
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/slim/code_attributes.rb', line 20 def on_html_attr(name, value) if value[0] == :slim && value[1] == :attrvalue && ![:merge_attrs][name] # We handle the attribute as a boolean attribute escape, code = value[2], value[3] case code when 'true' [:html, :attr, name, [:multi]] when 'false', 'nil' [:multi] else tmp = unique_name [:multi, [:code, "#{tmp} = #{code}"], [:if, tmp, [:if, "#{tmp} == true", [:html, :attr, name, [:multi]], [:html, :attr, name, [:escape, escape, [:dynamic, tmp]]]]]] end else # Attribute with merging @attr = name super end end |