Sinatra has a Mustache

5 Mar
There's a Github project to enable Sinatra with Mustache and the Mustache project itself has an example project, but I wanted a simple way, so I did this:

get '/woof' do
????mustache :doggy_template, :name => "Fido"
end

def mustache(template, args)
????Mustache.render File.new("#{:views}/#{template}.mustache", "r").read, args
end

Then I just stick "doggy.mustache" in /views, where you'd expect it. I'm probably missing something here, it seems to easy…but it worked for me!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: