gi / tilt-handlebars

A Tilt interface to the official JavaScript version of Handlebars.
MIT License
17 stars 5 forks source link

Template engine not found: handlebars #3

Closed mtrovo closed 9 years ago

mtrovo commented 10 years ago

I'm trying to run the provided example and it seems to be broken.

require 'sinatra'
require 'sinatra/handlebars'

class MyApp < Sinatra::Base
  helpers Sinatra::Handlebars

  get "/hello" do
    handlebars :index, locals: {name: 'Joe'}
  end

  run! if app_file == $0
end

Gives me

RuntimeError - Template engine not found: handlebars:
    /home/mtrovo/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:834:in `block in compile_template'
    /home/mtrovo/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/tilt-1.4.1/lib/tilt.rb:127:in `fetch'
    /home/mtrovo/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:832:in `compile_template'
    /home/mtrovo/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:813:in `render'
    /home/mtrovo/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/tilt-handlebars-1.3.1/lib/sinatra/handlebars.rb:4:in `handlebars'
    hbs.rb:8:in `block in <class:MyApp>'

My gems versions are:

commonsguy commented 9 years ago

You need to also require tilt/handlebars to make sinatra/handlebars work.

jimothyGator commented 9 years ago

@commonsguy : Thanks. I've fixed this in the develop branch so you don't need to require tilt/handlebars explicitly. I plan to release a new Gem once I've fixed #5 (memory leak).

But in the meantime, @mtrovo you may use @commonsguy's suggestion and just add the following to the top of your app:

require 'tilt/handlebars'
jimothyGator commented 9 years ago

Fixed in version 1.4.0.