Ruby changelog.com

handlebars.rb: Ruby Bindings for Handlebars.js

First there was Mustache, the nifty {}-based templating library from Defunkt. Then, Jan Lehnardt followed up with Mustache.js. Last month, we were excited to cover Handlebars.js, Yehuda Katz’ nifty riff on Mustache.js.

Now, we’ve come full circle as Charles Lowell (of Ruby Racer fame, covered in Episode 0.2.3) has created Handlebars.rb, Ruby bindings for Handlebars.js.

Handlebars.rb is not a port, it binds to the actual Handlebars.js code.

To use, clone Handlebars.rb into your project and pull down the required submodules with git submodule update. Now you can require the lib and render some templates:

require 'handlebars'
template = Handlebars.compile("{{say}}{{what}}")
template.call(:say => "Hey", :what => "Yuh!") #=> "Hey Yuh!"

[Source on GitHub]


Discussion

Sign in or join to comment

0:00 / 0:00