Sha256: 5a33e0f438d1a9bf8646eef6b2dcd2e6a2f04e5d0953a2528add1e1986404d8f

Contents?: true

Size: 734 Bytes

Versions: 32

Compression:

Stored size: 734 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::Core::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

32 entries across 32 versions & 1 rubygems

Version Path
nanoc-4.12.8 lib/nanoc/filters/haml.rb
nanoc-4.12.7 lib/nanoc/filters/haml.rb
nanoc-4.12.6 lib/nanoc/filters/haml.rb
nanoc-4.12.5 lib/nanoc/filters/haml.rb
nanoc-4.12.4 lib/nanoc/filters/haml.rb
nanoc-4.12.3 lib/nanoc/filters/haml.rb
nanoc-4.12.2 lib/nanoc/filters/haml.rb
nanoc-4.12.1 lib/nanoc/filters/haml.rb
nanoc-4.12.0 lib/nanoc/filters/haml.rb
nanoc-4.11.23 lib/nanoc/filters/haml.rb
nanoc-4.11.22 lib/nanoc/filters/haml.rb
nanoc-4.11.21 lib/nanoc/filters/haml.rb
nanoc-4.11.20 lib/nanoc/filters/haml.rb
nanoc-4.11.19 lib/nanoc/filters/haml.rb
nanoc-4.11.18 lib/nanoc/filters/haml.rb
nanoc-4.11.17 lib/nanoc/filters/haml.rb
nanoc-4.11.16 lib/nanoc/filters/haml.rb
nanoc-4.11.15 lib/nanoc/filters/haml.rb
nanoc-4.11.14 lib/nanoc/filters/haml.rb
nanoc-4.11.13 lib/nanoc/filters/haml.rb