Sha256: 80619fefed79e2a7ccc82fcdf49968c6b64b1801affea09a60c69068b18284a9

Contents?: true

Size: 680 Bytes

Versions: 42

Compression:

Stored size: 680 Bytes

Contents

module Nanoc::Filters
  # @api private
  class Haml < Nanoc::Filter
    requires 'haml'

    # Runs the content through [Haml](http://haml-lang.com/).
    # Parameters passed to this filter will be passed on to Haml.
    #
    # @param [String] content The content to filter
    #
    # @return [String] The filtered content
    def run(content, params = {})
      # Get options
      options = params.merge(filename: filename)

      # Create context
      context = ::Nanoc::Int::Context.new(assigns)

      # Get result
      proc = assigns[:content] ? -> { assigns[:content] } : nil
      ::Haml::Engine.new(content, options).render(context, assigns, &proc)
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
nanoc-4.0.0b4 lib/nanoc/filters/haml.rb
nanoc-4.0.0b3 lib/nanoc/filters/haml.rb