Sha256: ea5d6945239d320bbf0627764b0f09dbaf50ad1740310505df2b8dfbf03437ea

Contents?: true

Size: 981 Bytes

Versions: 8

Compression:

Stored size: 981 Bytes

Contents

# encoding: utf-8

module Nanoc::Filters
  class Erubis < Nanoc::Filter

    requires 'erubis'

    # The same as `::Erubis::Eruby` but adds `_erbout` as an alias for the
    # `_buf` variable, making it compatible with nanoc’s helpers that rely
    # on `_erbout`, such as {Nanoc::Helpers::Capturing}.
    class ErubisWithErbout < ::Erubis::Eruby
      include ::Erubis::ErboutEnhancer
    end

    # Runs the content through [Erubis](http://www.kuwata-lab.com/erubis/).
    # This method takes no options.
    #
    # @param [String] content The content to filter
    #
    # @return [String] The filtered content
    def run(content, params={})
      # Create context
      context = ::Nanoc::Context.new(assigns)

      # Get binding
      proc = assigns[:content] ? lambda { assigns[:content] } : nil
      assigns_binding = context.get_binding(&proc)

      # Get result
      ErubisWithErbout.new(content, :filename => filename).result(assigns_binding)
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
nanoc-3.6.7 lib/nanoc/filters/erubis.rb
nanoc-3.6.6 lib/nanoc/filters/erubis.rb
nanoc-3.6.5 lib/nanoc/filters/erubis.rb
nanoc-3.6.4 lib/nanoc/filters/erubis.rb
nanoc-3.6.3 lib/nanoc/filters/erubis.rb
nanoc-3.6.2 lib/nanoc/filters/erubis.rb
nanoc-3.6.1 lib/nanoc/filters/erubis.rb
nanoc-3.6.0 lib/nanoc/filters/erubis.rb