Class: Nanoc::Filters::ERB Private
- Inherits:
-
Nanoc::Filter
- Object
- Nanoc::Filters::ERB
- Defined in:
- lib/nanoc/filters/erb.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
-
#run(content, params = {}) ⇒ String
private
Runs the content through [ERB](ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html).
Instance Method Details
#run(content, params = {}) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Runs the content through [ERB](ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html).
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/nanoc/filters/erb.rb', line 17 def run(content, params = {}) # Add locals assigns.merge!(params[:locals] || {}) # Create context context = ::Nanoc::Core::Context.new(assigns) # Get binding proc = assigns[:content] ? -> { assigns[:content] } : nil assigns_binding = context.get_binding(&proc) # Get result trim_mode = params[:trim_mode] erb = ::ERB.new(content, trim_mode:) erb.filename = filename erb.result(assigns_binding) end |