Skip to content

Instantly share code, notes, and snippets.

@nesquena
Created May 5, 2011 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nesquena/956809 to your computer and use it in GitHub Desktop.
Save nesquena/956809 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'sinatra/base'
require 'padrino-helpers'
require 'padrino-core/application/rendering'
require 'erubis'
class SimpleApp < Sinatra::Base
include Padrino::Helpers
include Padrino::Rendering
get "/" do
erb :demo
end
end
SimpleApp.run!
@nesquena
Copy link
Author

nesquena commented May 5, 2011

In demo you are expected to render a partial. When I include the rendering module, this works. When I don't I get the template engine exception.

@nesquena
Copy link
Author

nesquena commented May 5, 2011

As long as you either

a) include the rendering module as shown here for Padrino 0.9.26 (which simply makes the render method more powerful)
b) use an explicit engine as shown partial("foo", :engine => :erb) in edge padrino after this commit right now

Note that b only works after changes I just made in Padrino so you must work off git because in edge padrino, I also added another way to get partials working without the need for augmenting rendering:

https://gist.github.com/956825

Option A works with stable gem Padrino. By adding rendering module you can also do things like this:

render 'foo' # rather than erb :foo

without an engine and Sinatra will autodetect that for you along with smarter rendering overall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment