Sha256: aed6cbee928ab7a271c3921b2727b348d0ae826aa18337847db0361178974ea7

Contents?: true

Size: 702 Bytes

Versions: 20

Compression:

Stored size: 702 Bytes

Contents

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

    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

20 entries across 20 versions & 1 rubygems

Version Path
nanoc-4.7.9 lib/nanoc/filters/haml.rb
nanoc-4.7.8 lib/nanoc/filters/haml.rb
nanoc-4.7.7 lib/nanoc/filters/haml.rb
nanoc-4.7.6 lib/nanoc/filters/haml.rb
nanoc-4.7.5 lib/nanoc/filters/haml.rb
nanoc-4.7.4 lib/nanoc/filters/haml.rb
nanoc-4.7.3 lib/nanoc/filters/haml.rb
nanoc-4.7.2 lib/nanoc/filters/haml.rb
nanoc-4.7.1 lib/nanoc/filters/haml.rb
nanoc-4.7.0 lib/nanoc/filters/haml.rb
nanoc-4.6.4 lib/nanoc/filters/haml.rb
nanoc-4.6.3 lib/nanoc/filters/haml.rb
nanoc-4.6.2 lib/nanoc/filters/haml.rb
nanoc-4.6.1 lib/nanoc/filters/haml.rb
nanoc-4.6.0 lib/nanoc/filters/haml.rb
nanoc-4.5.4 lib/nanoc/filters/haml.rb
nanoc-4.5.3 lib/nanoc/filters/haml.rb
nanoc-4.5.2 lib/nanoc/filters/haml.rb
nanoc-4.5.1 lib/nanoc/filters/haml.rb
nanoc-4.5.0 lib/nanoc/filters/haml.rb