Using Handlebars JS with Ruby on Rails!

What is Handlebars.js?

Handlebars official logo

Prerequisites

Let’s begin!
$ rails new handlebar-rails
$ rails g scaffold Book name price:integer author — skip-template-engine
resources :books, defaults: {format: :json}
gem 'handlebars_assets'
assets/javascripts/templates
//= require handlebars
//= require_tree ./templates
{{#books}}
<td>{{name}}</td>
<td>{{price}}</td>
<td>{{author}}</td>
{{/books}}
HandlebarsTemplates['book_list']({ books: data })
Generated html (left side) , Handlebars input(right side)
Handlebars CRUD

Ruby On Rails Developer, JavaScript Lead, Quick Learner, Reader, Writer, Always in Mood !!