Class: Nanoc::Filters::Erubi Private
- Inherits:
-
Nanoc::Filter
- Object
- Nanoc::Filters::Erubi
- Defined in:
- lib/nanoc/filters/erubi.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 [Erubi](github.com/jeremyevans/erubi).
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 [Erubi](github.com/jeremyevans/erubi). To prevent single quote escaping use :escapefunc => ‘Nanoc::Helpers::HTMLEscape.html_escape’ See the Erubi documentation for more options.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/nanoc/filters/erubi.rb', line 17 def run(content, params = {}) # Create context context = ::Nanoc::Core::Context.new(assigns) # Get binding proc = assigns[:content] ? -> { assigns[:content] } : nil assigns_binding = context.get_binding(&proc) # Get result engine_opts = { bufvar: '_erbout', filename: }.merge(params) engine = ::Erubi::Engine.new(content, engine_opts) eval(engine.src, assigns_binding, filename) end |