Module: Jekyll::Filters::Nokogiri
- Defined in:
- lib/jekyll/filters/nokogiri.rb
Instance Method Summary collapse
-
#add_attribute(input, filter, attribute, value) ⇒ String
Adds an attribute to all elements matching a CSS filter.
Instance Method Details
#add_attribute(input, filter, attribute, value) ⇒ String
Adds an attribute to all elements matching a CSS filter.
17 18 19 20 21 22 23 |
# File 'lib/jekyll/filters/nokogiri.rb', line 17 def add_attribute(input, filter, attribute, value) ::Nokogiri::HTML5.fragment(input).tap do |html_fragment| html_fragment.css(filter).each do |element| element[attribute] = value.to_s end end.to_s end |