Sha256: 4df152b4f7cfe4c5953b10a86e743c2850bf169db080185d0357d7313d2e9890

Contents?: true

Size: 682 Bytes

Versions: 4

Compression:

Stored size: 682 Bytes

Contents

# encoding: utf-8

module Nanoc3::Filters
  class Erubis < Nanoc3::Filter

    # 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={})
      require 'erubis'

      # Create context
      context = ::Nanoc3::Context.new(assigns)

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

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

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nanoc3-3.1.9 lib/nanoc3/filters/erubis.rb
nanoc3-3.1.8 lib/nanoc3/filters/erubis.rb
nanoc3-3.2.0a4 lib/nanoc3/filters/erubis.rb
nanoc3-3.1.7 lib/nanoc3/filters/erubis.rb