Sha256: b36e1f598385cd808be812d1347bd090126d56363ab57858dfdb5a632cf39684

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

## Handlebars.rb

This uses [therubyracer][1] to bind to the _actual_ JavaScript implementation of
[Handlebars.js][2] so that you can use it from ruby.

## Usage

Simple stuff

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

With functions as properties

    template.call(:say => "Hey", :what => lambda {|this| ("yo" * 2) + "!"}) #=> "Hey yoyo!"

Register block helpers:

    handlebars.register_helper(:twice) do |block|
      "#{block.call}#{block.call}"
    end
    template = handlebars.compile({{#twice}}Hurray!{{/twice}})
    template.call #=> Hurray!Hurray!

## Hack

    git clone git@github.com:cowboyd/handlebars.rb.git #git it
    cd handlebars.rb #go to it
    git submodule update --init #pull down handlebars.js
    rspec spec/ #test it


## Rubygems

  Handlebars is available via the [hbs][3] gem on rubygems.org. There is also a
  [handlebars][4] gem, which is a pure-ruby implementation that appears to no longer be maintained.

[1]: http://github.com/cowboyd/therubyracer "The Ruby Racer"
[2]: http://github.com/wycats/handlebars.js "Handlebars JavaScript templating library"
[3]: http://rubygems.org/gems/hbs "handelbars gem in JavaScript"
[4]: http://rubygems.org/gems/handlebars "pure ruby handlebars gem"

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
handlebars-0.3.0 README.mdown
handlebars-0.2.2 README.mdown
handlebars-0.2.1 README.mdown