Class: Volt::Slim::Filters::CodeAttributes Private
- Inherits:
-
Slim::Filter
- Object
- Slim::Filter
- Volt::Slim::Filters::CodeAttributes
- Defined in:
- lib/volt/slim/filters/code_attributes.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
-
#on_html_attr(name, value) ⇒ Array
private
Handle attribute expression ‘[:html, :attr, name, value]`.
-
#on_html_attrs(*attrs) ⇒ Array
private
Handle attributes expression ‘[:html, :attrs, *attrs]`.
-
#on_slim_attrvalue(escape, code) ⇒ Array
private
Handle attribute expression ‘[:slim, :attrvalue, escape, code]`.
Instance Method Details
#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]`
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/volt/slim/filters/code_attributes.rb', line 22 def on_html_attr(name, value) if value[0] == :slim && value[1] == :attrvalue # && !options[: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 [:html, :attr, name, [:dynamic, code]] end else # Attribute with merging @attr = name super end end |
#on_html_attrs(*attrs) ⇒ 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 attributes expression ‘[:html, :attrs, *attrs]`
13 14 15 |
# File 'lib/volt/slim/filters/code_attributes.rb', line 13 def on_html_attrs(*attrs) [:multi, *attrs.map {|a| compile(a) }] end |
#on_slim_attrvalue(escape, code) ⇒ 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 ‘[:slim, :attrvalue, escape, code]`
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/volt/slim/filters/code_attributes.rb', line 46 def on_slim_attrvalue(escape, code) # We perform attribute merging on Array values # if delimiter = options[:merge_attrs][@attr] # tmp = unique_name # [:multi, # [:code, "#{tmp} = #{code}"], # [:if, "Array === #{tmp}", # [:multi, # [:code, "#{tmp} = #{tmp}.flatten"], # [:code, "#{tmp}.map!(&:to_s)"], # [:code, "#{tmp}.reject!(&:empty?)"], # [:escape, escape, [:dynamic, "#{tmp}.join(#{delimiter.inspect})"]]], # [:escape, escape, [:dynamic, tmp]]]] # else [:dynamic, code] # end end |