Sha256: 3fe6f454ec5fc7aee5a00f3dd6df291378cc4c3dc6fd49ae5238e624762079ec

Contents?: true

Size: 1.08 KB

Versions: 7

Compression:

Stored size: 1.08 KB

Contents

# encoding: utf-8

class Nanoc::Filters::MustacheTest < MiniTest::Unit::TestCase

  include Nanoc::TestHelpers

  def test_filter
    if_have 'mustache' do
      # Create item
      item = Nanoc::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.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::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.run('Max says: {{yield}}.')
      assert_equal('Max says: No Payne No Gayne.', result)
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
nanoc-3.5.0 test/filters/test_mustache.rb
nanoc-3.5.0b2 test/filters/test_mustache.rb
nanoc-3.5.0b1 test/filters/test_mustache.rb
nanoc-3.4.3 test/filters/test_mustache.rb
nanoc-3.4.2 test/filters/test_mustache.rb
nanoc-3.4.1 test/filters/test_mustache.rb
nanoc-3.4.0 test/filters/test_mustache.rb