Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
46 lines (31 sloc) 1.24 KB


To simplify setting up Sinatra to use Mustache for it's templates

Sinatra is a pretty amazing little web framework, if you don't know much about it you should take some time to get to know it.

Mustache is also another favorite of mine; a really great and simple templating system. I have been slowly converting all my old views in various projects over to it.


There is already an official way to get Mustache to work with Sinatra, which involves some work and requires separate view classes to accompany your mustache templates. While I see the power in that it seems a bit complex..


Try this on:

require 'sinatra/mustache'

class App < Sinatra::Base
  set :views, 'templates' # totally optional

And then put your .mustache files in your app's views folder

Instance variables and locals are available to the template as well as yaml front matter.


If you need the extra support of the ruby views used in the official Mustache for Sinatra example this gem probably isn't for you.

Jump to Line
Something went wrong with that request. Please try again.