Sha256: c382f0a2697e8b88b3f553d673198cc6fb6b088284827c7b62e1f2d8bcedcc54

Contents?: true

Size: 733 Bytes

Versions: 41

Compression:

Stored size: 733 Bytes

Contents

# frozen_string_literal: true

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

41 entries across 41 versions & 1 rubygems

Version Path
nanoc-4.11.0 lib/nanoc/filters/haml.rb
nanoc-4.10.4 lib/nanoc/filters/haml.rb
nanoc-4.10.3 lib/nanoc/filters/haml.rb
nanoc-4.10.2 lib/nanoc/filters/haml.rb
nanoc-4.10.1 lib/nanoc/filters/haml.rb
nanoc-4.10.0 lib/nanoc/filters/haml.rb
nanoc-4.9.9 lib/nanoc/filters/haml.rb
nanoc-4.9.8 lib/nanoc/filters/haml.rb
nanoc-4.9.7 lib/nanoc/filters/haml.rb
nanoc-4.9.6 lib/nanoc/filters/haml.rb
nanoc-4.9.5 lib/nanoc/filters/haml.rb
nanoc-4.9.4 lib/nanoc/filters/haml.rb
nanoc-4.9.3 lib/nanoc/filters/haml.rb
nanoc-4.9.2 lib/nanoc/filters/haml.rb
nanoc-4.9.1 lib/nanoc/filters/haml.rb
nanoc-4.9.0 lib/nanoc/filters/haml.rb
nanoc-4.8.19 lib/nanoc/filters/haml.rb
nanoc-4.8.18 lib/nanoc/filters/haml.rb
nanoc-4.8.17 lib/nanoc/filters/haml.rb
nanoc-4.8.16 lib/nanoc/filters/haml.rb