Sha256: a2c6e319b3e60412238f0c938aa4f6512e403b8f76197686358498a47d78ed57

Contents?: true

Size: 682 Bytes

Versions: 8

Compression:

Stored size: 682 Bytes

Contents

# encoding: utf-8

require 'haml'

module Nanoc3::Filters
  class Haml < Nanoc3::Filter

    # 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 = ::Nanoc3::Context.new(assigns)

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

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
nanoc3-3.2.4 lib/nanoc3/filters/haml.rb
nanoc3-3.2.3 lib/nanoc3/filters/haml.rb
nanoc3-3.2.2 lib/nanoc3/filters/haml.rb
nanoc3-3.2.1 lib/nanoc3/filters/haml.rb
nanoc3-3.2.0 lib/nanoc3/filters/haml.rb
nanoc3-3.2.0b3 lib/nanoc3/filters/haml.rb
nanoc3-3.2.0b2 lib/nanoc3/filters/haml.rb
nanoc3-3.2.0b1 lib/nanoc3/filters/haml.rb