class Temple::HTML::AttributeSorter

This filter sorts html attributes. @api public

Public Instance Methods

call(exp) click to toggle source
Calls superclass method
# File lib/temple/html/attribute_sorter.rb, line 9
def call(exp)
  options[:sort_attrs] ? super : exp
end
on_html_attrs(*attrs) click to toggle source
# File lib/temple/html/attribute_sorter.rb, line 13
def on_html_attrs(*attrs)
  n = 0 # Use n to make sort stable. This is important because the merger could be executed afterwards.
  [:html, :attrs, *attrs.sort_by do |attr|
    raise(InvalidExpression, 'Attribute is not a html attr') if attr[0] != :html || attr[1] != :attr
    [attr[2].to_s, n += 1]
  end]
end