Sha256: 3bd0124fa09472758898fdffab7d01ffca10e2c3da9cd505639d620920cb64bb

Contents?: true

Size: 686 Bytes

Versions: 9

Compression:

Stored size: 686 Bytes

Contents

# encoding: utf-8

module Nanoc::Filters
  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::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

9 entries across 9 versions & 1 rubygems

Version Path
nanoc-3.7.4 lib/nanoc/filters/haml.rb
nanoc-3.7.3 lib/nanoc/filters/haml.rb
nanoc-3.7.2 lib/nanoc/filters/haml.rb
nanoc-3.7.1 lib/nanoc/filters/haml.rb
nanoc-3.7.0 lib/nanoc/filters/haml.rb
nanoc-3.6.11 lib/nanoc/filters/haml.rb
nanoc-3.6.10 lib/nanoc/filters/haml.rb
nanoc-3.6.9 lib/nanoc/filters/haml.rb
nanoc-3.6.8 lib/nanoc/filters/haml.rb