Sha256: 32411cc55ef0b88f03a1f08a3e4d18cf2e7abae63c57693bf3552dd6a7c5f7c3

Contents?: true

Size: 745 Bytes

Versions: 41

Compression:

Stored size: 745 Bytes

Contents

# frozen_string_literal: true

module Nanoc::Filters
  # @api private
  class Slim < Nanoc::Filter
    identifier :slim

    requires 'slim'

    # Runs the content through [Slim](http://slim-lang.com/).
    # This method takes no options.
    #
    # @param [String] content The content to filter
    #
    # @return [String] The filtered content
    def run(content, params = {})
      params = {
        disable_capture: true, # Capture managed by Nanoc
        buffer: '_erbout', # Force slim to output to the buffer used by Nanoc
      }.merge params

      # Create context
      context = ::Nanoc::Int::Context.new(assigns)

      ::Slim::Template.new(filename, params) { content }.render(context) { assigns[:content] }
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
nanoc-4.7.10 lib/nanoc/filters/slim.rb