Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 4b782bba13
Fetching contributors…

Cannot retrieve contributors at this time

46 lines (31 sloc) 1.268 kB

sinatra-mustache

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.

Why?

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..

Usage

Try this on:

require 'sinatra/mustache'

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

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.

Caveat

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.