Sha256: c6747785a9754598c3e6cb8ad963378c3914b650f6bfad63f548b779eeee81bc

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

require 'helper'

class Nanoc::Filters::MustacheTest < Nanoc::TestCase
  def test_filter
    if_have 'mustache' do
      # Create item
      item = Nanoc::Int::Item.new(
        'content',
        { title: 'Max Payne', protagonist: 'Max Payne' },
        '/games/max-payne/',
      )

      # Create filter
      filter = ::Nanoc::Filters::Mustache.new(item: item)

      # Run filter
      result = filter.setup_and_run('The protagonist of {{title}} is {{protagonist}}.')
      assert_equal('The protagonist of Max Payne is Max Payne.', result)
    end
  end

  def test_filter_with_yield
    if_have 'mustache' do
      # Create item
      item = Nanoc::Int::Item.new(
        'content',
        { title: 'Max Payne', protagonist: 'Max Payne' },
        '/games/max-payne/',
      )

      # Create filter
      filter = ::Nanoc::Filters::Mustache.new(
        content: 'No Payne No Gayne', item: item,
      )

      # Run filter
      result = filter.setup_and_run('Max says: {{yield}}.')
      assert_equal('Max says: No Payne No Gayne.', result)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
nanoc-4.8.2 test/filters/test_mustache.rb
nanoc-4.8.1 test/filters/test_mustache.rb
nanoc-4.8.0 test/filters/test_mustache.rb
nanoc-4.7.14 test/filters/test_mustache.rb
nanoc-4.7.13 test/filters/test_mustache.rb
nanoc-4.7.12 test/filters/test_mustache.rb
nanoc-4.7.11 test/filters/test_mustache.rb
nanoc-4.7.10 test/filters/test_mustache.rb