Sha256: 4a992cdbddec9bb0bf5215ca5b4659198de2585ed6975031883c9a22347feab8

Contents?: true

Size: 1.06 KB

Versions: 15

Compression:

Stored size: 1.06 KB

Contents

# encoding: utf-8

class Nanoc::Filters::MustacheTest < Nanoc::TestCase

  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.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::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

15 entries across 15 versions & 1 rubygems

Version Path
nanoc-3.7.4 test/filters/test_mustache.rb
nanoc-3.7.3 test/filters/test_mustache.rb
nanoc-3.7.2 test/filters/test_mustache.rb
nanoc-3.7.1 test/filters/test_mustache.rb
nanoc-3.7.0 test/filters/test_mustache.rb
nanoc-3.6.11 test/filters/test_mustache.rb
nanoc-3.6.10 test/filters/test_mustache.rb
nanoc-3.6.9 test/filters/test_mustache.rb
nanoc-3.6.8 test/filters/test_mustache.rb
nanoc-3.6.7 test/filters/test_mustache.rb
nanoc-3.6.6 test/filters/test_mustache.rb
nanoc-3.6.5 test/filters/test_mustache.rb
nanoc-3.6.4 test/filters/test_mustache.rb
nanoc-3.6.3 test/filters/test_mustache.rb
nanoc-3.6.2 test/filters/test_mustache.rb