Module: Nanoc::Helpers::Filtering
- Includes:
- Capturing
- Defined in:
- lib/nanoc/helpers/filtering.rb
Overview
Instance Method Summary collapse
Methods included from Capturing
Instance Method Details
#filter(filter_name, arguments = {}, &block) ⇒ void
This method returns an undefined value.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/nanoc/helpers/filtering.rb', line 13 def filter(filter_name, arguments = {}, &block) # Capture block data = capture(&block) # Find filter klass = Nanoc::Filter.named!(filter_name) # Create filter assigns = { item: @item, rep: @rep, item_rep: @item_rep, items: @items, layouts: @layouts, config: @config, content: @content, } filter = klass.new(assigns) # Filter captured data Nanoc::Core::NotificationCenter.post(:filtering_started, @item_rep._unwrap, filter_name) filtered_data = filter.setup_and_run(data, arguments) Nanoc::Core::NotificationCenter.post(:filtering_ended, @item_rep._unwrap, filter_name) # Append filtered data to buffer buffer = eval('_erbout', block.binding) buffer << filtered_data end |