/usr/lib/ruby/vendor_ruby/temple/html/attribute_sorter.rb is in ruby-temple 0.6.7-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | module Temple
module HTML
# This filter sorts html attributes.
# @api public
class AttributeSorter < Filter
define_options :sort_attrs => true
def call(exp)
options[:sort_attrs] ? super : exp
end
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
end
end
end
|