Class: Nanoc::Tilt::Filter
- Inherits:
-
Filter
- Object
- Filter
- Nanoc::Tilt::Filter
- Defined in:
- lib/nanoc/tilt/filter.rb
Instance Method Summary collapse
-
#run(content, params = {}) ⇒ String
Runs the content through [Tilt](github.com/rtomayko/tilt).
Instance Method Details
#run(content, params = {}) ⇒ String
Runs the content through [Tilt](github.com/rtomayko/tilt). Parameters passed as ‘:args` will be passed on to Tilt.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/nanoc/tilt/filter.rb', line 14 def run(content, params = {}) # Get options = params.fetch(:args, {}) # Create context context = ::Nanoc::Core::Context.new(assigns) # Get result proc = assigns[:content] ? -> { assigns[:content] } : nil # Find Tilt template class ext = item.identifier.ext || item[:extension] template_class = ::Tilt[ext] # Render template = template_class.new() { content } template.render(context, assigns, &proc) end |