Sha256: e1c50ee4ab88e357ccc0b7429aa2efa8161f05d4424ecbd6303ab9c25cee1788

Contents?: true

Size: 701 Bytes

Versions: 2

Compression:

Stored size: 701 Bytes

Contents

# encoding: utf-8

module Nanoc::Filters
  # @since 3.2.0
  class Slim < Nanoc::Filter
    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::Context.new(assigns)

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nanoc-3.8.0 lib/nanoc/filters/slim.rb
nanoc-3.7.5 lib/nanoc/filters/slim.rb