Sha256: 2c7bd27a7a7bddb88cee76000ee5c35575f2655389c30094f02f33e88e72330a

Contents?: true

Size: 688 Bytes

Versions: 4

Compression:

Stored size: 688 Bytes

Contents

# encoding: utf-8

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={})
      require 'haml'

      # 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

4 entries across 4 versions & 1 rubygems

Version Path
nanoc3-3.1.9 lib/nanoc3/filters/haml.rb
nanoc3-3.1.8 lib/nanoc3/filters/haml.rb
nanoc3-3.2.0a4 lib/nanoc3/filters/haml.rb
nanoc3-3.1.7 lib/nanoc3/filters/haml.rb