Class: Nanoc::Filters::Haml Private
- Inherits:
-
Nanoc::Filter
- Object
- Nanoc::Filters::Haml
- Defined in:
- lib/nanoc/filters/haml.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 [Haml](haml-lang.com/).
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 [Haml](haml-lang.com/). Parameters passed to this filter will be passed on to Haml.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/nanoc/filters/haml.rb', line 16 def run(content, params = {}) # Get options = params.merge(filename:) # Create context context = ::Nanoc::Core::Context.new(assigns) # Get result proc = assigns[:content] ? -> { assigns[:content] } : nil # Render haml_major_version = ::Haml::VERSION[0] case haml_major_version when '5' ::Haml::Engine.new(content, ).render(context, assigns, &proc) when '6' template = Tilt::HamlTemplate.new() { content } template.render(context, assigns, &proc) else raise Nanoc::Core::TrivialError.new( "Cannot run Haml filter: unsupported Haml major version: #{haml_major_version}", ) end end |