This is just to document that mustache is also working fine in a
classic top-level style Sinatra application. Compared with the
existing modular style example there are 3 small differences:
1. calling the app with "run Sinatra::Application"
2. "register Mustache::Sinatra" is not needed
3. view classes are not, for example, named "App::Views::Home" but
just "Home"
-----
config.ru -----
require 'simple'
run Sinatra::Application
----- simple.rb -----
require 'rubygems'
require 'sinatra'
require 'mustache/sinatra'
set :views, 'templates/'
set :mustaches, 'views/'
get '/' do
mustache :home
end
----- templates/home.mustache -----
<p>This is a nice quotation: "{{content}}"</p>
----- views/home.rb -----
class Home < Mustache
def content
"Hello beautiful world!"
end
end
Starting the app with "shotgun
config.ru" enables nice application
reloading after changing
either 1. the top-level app file, e.g. simple.rb, or 2. a template
file or 3. a view ruby file
-- Bert