Module: Nanoc3::Helpers::Filtering
Included Modules
Nanoc3::Helpers::Filtering provides a filter method, which allows parts of an item to be filtered.
For example, the following piece of code only runs the "rubypants" filter on the second paragraph:
<p>Lorem ipsum dolor sit amet...</p> <% filter :rubypants do %> <p>Consectetur adipisicing elit...</p> <% end %>
This helper likely only works with ERB (and perhaps Erubis).
To activate this helper, include it, like this:
include Nanoc3::Helpers::Filtering
Public Visibility
Public Instance Method Summary
| #filter(filter_name, arguments = {}, &block) |
Filters the content in the given block and outputs it. |
|---|
Public Instance Methods Included from Nanoc3::Helpers::Capturing
Public Instance Method Details
filter
public
filter(filter_name, arguments = {}, &block)
Filters the content in the given block and outputs it.
[View source]
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/nanoc3/helpers/filtering.rb', line 27 def filter(filter_name, arguments={}, &block) # Capture block data = capture(&block) # Find filter klass = Nanoc3::Filter.named(filter_name) raise Nanoc3::Errors::UnknownFilter.new(filter_name) if klass.nil? filter = klass.new(@item_rep.assigns) # Filter captured data filtered_data = filter.run(data, arguments) # Append filtered data to buffer buffer = eval('_erbout', block.binding) buffer << filtered_data end |