Sha256: 42e4868f931c633da8183f7725fbc8932f1e1b1a7d1235a5088d2ccdc9159d18

Contents?: true

Size: 1.7 KB

Versions: 18

Compression:

Stored size: 1.7 KB

Contents

class Nanoc::Filters::HandlebarsTest < Nanoc::TestCase
  def test_filter
    if_have 'handlebars' do
      # Create data
      item = Nanoc::Int::Item.new(
        'content',
        { title: 'Max Payne', protagonist: 'Max Payne', location: 'here' },
        '/games/max-payne/')
      layout = Nanoc::Int::Layout.new(
        'layout content',
        { name: 'Max Payne' },
        '/default/')
      config = { animals: 'cats and dogs' }

      # Create filter
      assigns = {
        item: item,
        layout: layout,
        config: config,
        content: 'No Payne No Gayne',
      }
      filter = ::Nanoc::Filters::Handlebars.new(assigns)

      # Run filter
      result = filter.setup_and_run('{{protagonist}} says: {{yield}}.')
      assert_equal('Max Payne says: No Payne No Gayne.', result)
      result = filter.setup_and_run('We can’t stop {{item.location}}! This is the {{layout.name}} layout!')
      assert_equal('We can’t stop here! This is the Max Payne layout!', result)
      result = filter.setup_and_run('It’s raining {{config.animals}} here!')
      assert_equal('It’s raining cats and dogs here!', result)
    end
  end

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

      # Create filter
      assigns = {
        item: item,
        content: 'No Payne No Gayne',
      }
      filter = ::Nanoc::Filters::Handlebars.new(assigns)

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

Version data entries

18 entries across 18 versions & 1 rubygems

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