Class: NanocHtmlPipeline::Filter
- Inherits:
-
Nanoc::Filter
- Object
- Nanoc::Filter
- NanocHtmlPipeline::Filter
- Defined in:
- lib/nanoc-html-pipeline/filter.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#run(content, params = {}) ⇒ String
The filtered content.
Class Method Details
.filter_key(s) ⇒ Object
11 12 13 |
# File 'lib/nanoc-html-pipeline/filter.rb', line 11 def self.filter_key(s) s.to_s.downcase.to_sym end |
.is_filter(f) ⇒ Object
15 16 17 18 19 |
# File 'lib/nanoc-html-pipeline/filter.rb', line 15 def self.is_filter(f) f < HTML::Pipeline::Filter rescue LoadError, ArgumentError false end |
Instance Method Details
#run(content, params = {}) ⇒ String
Returns The filtered content.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/nanoc-html-pipeline/filter.rb', line 27 def run(content, params={}) # Get options = {:pipeline => []}.merge(params) filters = .delete(:pipeline).map do |f| if self.class.is_filter(f) f else key = self.class.filter_key(f) filter = HTML::Pipeline.constants.find { |c| c.downcase == key } # possibly a custom filter if filter.nil? Nanoc.const_get(f) else HTML::Pipeline.const_get(filter) end end end HTML::Pipeline.new(filters, ).to_html(content) end |