Sha256: efac33dd4d1b91ebc92ade1dc77a6fb1b8c24d77c98ad07ac97c9093869097e6

Contents?: true

Size: 978 Bytes

Versions: 39

Compression:

Stored size: 978 Bytes

Contents

module Nanoc::Filters
  # @api private
  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::Int::Context.new(assigns)

      # Get binding
      proc = assigns[:content] ? -> { 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

39 entries across 39 versions & 1 rubygems

Version Path
nanoc-4.2.1 lib/nanoc/filters/erubis.rb
nanoc-4.2.0 lib/nanoc/filters/erubis.rb
nanoc-4.1.6 lib/nanoc/filters/erubis.rb
nanoc-4.2.0b1 lib/nanoc/filters/erubis.rb
nanoc-4.1.5 lib/nanoc/filters/erubis.rb
nanoc-4.1.4 lib/nanoc/filters/erubis.rb
nanoc-4.1.3 lib/nanoc/filters/erubis.rb
nanoc-4.1.2 lib/nanoc/filters/erubis.rb
nanoc-4.1.1 lib/nanoc/filters/erubis.rb
nanoc-4.1.0 lib/nanoc/filters/erubis.rb
nanoc-4.1.0rc2 lib/nanoc/filters/erubis.rb
nanoc-4.1.0rc1 lib/nanoc/filters/erubis.rb
nanoc-4.1.0b1 lib/nanoc/filters/erubis.rb
nanoc-4.1.0a1 lib/nanoc/filters/erubis.rb
nanoc-4.0.2 lib/nanoc/filters/erubis.rb
nanoc-4.0.1 lib/nanoc/filters/erubis.rb
nanoc-4.0.0 lib/nanoc/filters/erubis.rb
nanoc-4.0.0rc3 lib/nanoc/filters/erubis.rb
nanoc-4.0.0rc2 lib/nanoc/filters/erubis.rb