Sha256: 5e2419a84be4b8e025d3a4955792f6cfa070c42ea35ba7149d1c4b2c795b705f

Contents?: true

Size: 699 Bytes

Versions: 4

Compression:

Stored size: 699 Bytes

Contents

# encoding: utf-8

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

4 entries across 4 versions & 1 rubygems

Version Path
nanoc-4.0.0b2 lib/nanoc/filters/haml.rb
nanoc-4.0.0b1 lib/nanoc/filters/haml.rb
nanoc-4.0.0a2 lib/nanoc/filters/haml.rb
nanoc-4.0.0a1 lib/nanoc/filters/haml.rb