{"id":1795,"date":"2017-03-14T09:48:19","date_gmt":"2017-03-14T09:48:19","guid":{"rendered":"https:\/\/www.botreetechnologies.com\/blog\/?p=1795"},"modified":"2021-09-08T17:38:06","modified_gmt":"2021-09-08T12:08:06","slug":"using-handlebars-js-with-ruby-on-rails","status":"publish","type":"post","link":"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/","title":{"rendered":"Using Handlebars JS with Ruby on Rails!"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">What is Handlebars.js?<\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"705\" height=\"205\" src=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/handlebars-js.png\" alt=\"What is Handlebars js\" class=\"wp-image-13890\" srcset=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/handlebars-js.png 705w, https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/handlebars-js-300x87.png 300w\" sizes=\"auto, (max-width: 705px) 100vw, 705px\" \/><\/figure><\/div>\n\n\n\n<p><a href=\"https:\/\/github.com\/wycats\/handlebars.js\/\" target=\"_blank\" rel=\"noopener noreferrer\">Handlebars<\/a>&nbsp;allows to build semantic templates. Handlebars is largely compatible with <a href=\"https:\/\/en.wikipedia.org\/wiki\/Mustache_%28template_system%29\" target=\"_blank\" rel=\"noopener noreferrer\">Mustache templates<\/a>. In most cases it is possible to swap out Mustache with Handlebars and continue using your current templates.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Official Handlebars Docs:\u00a0<a href=\"https:\/\/handlebarsjs.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/www.handlebarsjs.com<\/a><\/p><p>Live demo:\u00a0<a href=\"http:\/\/tryhandlebarsjs.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/tryhandlebarsjs.com\/<\/a><\/p><\/blockquote>\n\n\n\n<p><b>Now let&#8217;s get started!<\/b><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Prerequisites<\/h3>\n\n\n\n<p>Before you get started, make sure you have\u00a0<a href=\"https:\/\/rvm.io\/\" target=\"_blank\" rel=\"noreferrer noopener\"><b>RVM<\/b><\/a>,\u00a0<a href=\"https:\/\/www.ruby-lang.org\/en\/\" target=\"_blank\" rel=\"noreferrer noopener\"><b>Ruby<\/b><\/a>\u00a0and\u00a0<a href=\"https:\/\/rubyonrails.org\/\" target=\"_blank\" rel=\"noreferrer noopener\"><b>Rails<\/b><\/a>\u00a0installed on your machine. If you don&#8217;t, please follow the instructions here:\u00a0<a href=\"https:\/\/gorails.com\/setup\/ubuntu\/14.04\" target=\"_blank\" rel=\"noreferrer noopener\">How To Install Ruby on Rails on Ubuntu<\/a>.<\/p>\n\n\n\n<p>Below version of&nbsp;<a href=\"https:\/\/www.botreetechnologies.com\/ruby-on-rails-development\" target=\"_blank\" rel=\"noopener noreferrer\">Ruby and Rails<\/a>&nbsp;were used in this tutorial<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Rails 5.0.2<br>Ruby 2.2.3<\/p><\/blockquote>\n\n\n\n<p>You can find the full source code of this tutorial\u00a0<a href=\"https:\/\/github.com\/AnkurVyas-BTC\/handlebar-rails\" target=\"_blank\" rel=\"noreferrer noopener\"><b>handlebar-rails<\/b><\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"425\" src=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/lets-begain.jpeg\" alt=\"Let's begin!\" class=\"wp-image-13891\" srcset=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/lets-begain.jpeg 1000w, https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/lets-begain-300x128.jpeg 300w, https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/lets-begain-768x326.jpeg 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><figcaption>Let&#8217;s begin!<\/figcaption><\/figure>\n\n\n\n<p>Start by creating brand new rails app.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><code>$ rails new handlebar-rails<\/code><\/p><\/blockquote>\n\n\n\n<p>Add\u00a0<a href=\"https:\/\/github.com\/seyhunak\/twitter-bootstrap-rails#installing-the-gem\" target=\"_blank\" rel=\"noreferrer noopener\"><b>bootstrap gem<\/b><\/a>\u00a0to apply some styling to your pages. Of course this is optional!<\/p>\n\n\n\n<p>Let&#8217;s create the API for the books model which we will use in this tutorial.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><code>$ rails g scaffold Book name price:integer author - skip-template-engine<\/code><\/p><\/blockquote>\n\n\n\n<p>Adding\u200a<i>&#8211;<b>skip-template-engine<\/b><\/i>&nbsp;will create API without html views.<\/p>\n\n\n\n<p>As we would use books routes as an API only, we set default format as JSON in&nbsp;<i><b>config\/routes.rb<\/b><\/i>&nbsp;file of our app. Doing so will send all the request as JSON.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><code>resources :books, defaults: {format: :json}<\/code><\/p><\/blockquote>\n\n\n\n<p>Now let&#8217;s add&nbsp;<a href=\"https:\/\/github.com\/leshill\/handlebars_assets\" target=\"_blank\" rel=\"noopener noreferrer\">handlebars<\/a>&nbsp;gem to our&nbsp;<i><b>Gemfile<\/b><\/i>.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><code>gem 'handlebars_assets'<\/code><\/p><\/blockquote>\n\n\n\n<p>and then do&nbsp;<b><i><code>$ bundle install<\/code><\/i><\/b>&nbsp;so it gets installed in the rails app.<\/p>\n\n\n\n<p>As we are working with semantic JS templates they need to be organized in&nbsp;<i><b>assets\/javascripts<\/b><\/i>&nbsp;folder.<\/p>\n\n\n\n<p>Create directory named&nbsp;<i><b>templates<\/b><\/i> in the&nbsp;<i><b>assets\/javascripts<\/b><\/i>&nbsp;folder as suggested in the&nbsp;<a href=\"https:\/\/github.com\/leshill\/handlebars_assets#templates-directory\" target=\"_blank\" rel=\"noopener noreferrer\">official documentation<\/a>&nbsp;of the handlebars gem. So it will have the below structure.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>assets\/javascripts\/templates<\/p><\/blockquote>\n\n\n\n<p>Now add following to your&nbsp;<i><b>application.js<\/b><\/i>&nbsp;manifest file.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><code>\/\/= require handlebars<br>\n\/\/= require_tree .\/templates<\/code><\/p><\/blockquote>\n\n\n\n<p>Note:&nbsp;Make sure you keep it before&nbsp;<i><b><code>\/\/= require_tree&nbsp;.<\/code><\/b><\/i>&nbsp;else you will be running into major problems.<\/p>\n\n\n\n<p>Now let&#8217;s add our first Handlebars template <i><b>book_list.hbs<\/b><\/i>&nbsp;to our app.<\/p>\n\n\n\n<p><script src=\"https:\/\/gist.github.com\/AnkurVyas-BTC\/2c2c7a76211f0286e09b1ced4283ccc2.js\"><\/script><\/p>\n\n\n\n<p>One new thing that you will notice here is&nbsp;{{}}&nbsp;block, anything written in this block is considered as dynamic code and will be evaluated by handlebars at run-time. It is similar to the code written as&nbsp;&#8220;#{a+b}&#8221;&nbsp;which is termed as&nbsp;<a href=\"http:\/\/ruby-for-beginners.rubymonstas.org\/bonus\/string_interpolation.html\" target=\"_blank\" rel=\"noopener noreferrer\">string interpolation<\/a>&nbsp;in ruby.<\/p>\n\n\n\n<p>Here all the code written between\u00a0{{#books}}\u00a0&#8230; {{\/books}}\u00a0is looped on the\u00a0books\u00a0object. Handlebars provide some\u00a0built-in helpers\u00a0so we will use them right out of the box.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><code>{{#books}}<br>\n&lt;td&gt;{{name}}&lt;\/td&gt;<br>\n&lt;td&gt;{{price}}&lt;\/td&gt;<br>\n&lt;td&gt;{{author}}&lt;\/td&gt;<br>\n{{\/books}}<\/code><\/p><\/blockquote>\n\n\n\n<p>Above will treat&nbsp;<i><b>name<\/b><\/i> as&nbsp;<i><b>book.name<\/b><\/i>&nbsp;as it is looped within books object loop. Same applies to&nbsp;<i><b>price<\/b><\/i> and&nbsp;<b><i>author<\/i><\/b>.<\/p>\n\n\n\n<p>Any handlebar templates can be invoked using<\/p>\n\n\n\n<p>HandlebarsTemplates[&lt;template_name&gt;](context)<\/p>\n\n\n\n<p>As for example,<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><code>HandlebarsTemplates['book_list']({ books: data })<\/code><\/p><\/blockquote>\n\n\n\n<p>Here it searches&nbsp;<i><b>assets\/javascripts\/templates\/book_list.hbs<\/b><\/i>&nbsp;template and pass contents of&nbsp;<i><b>data<\/b><\/i> as <i><b>books<\/b><\/i>&nbsp;object to the template.<\/p>\n\n\n\n<p>You can also check html output of the same in console of your web browser. That&#8217;s pretty cool!<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"320\" src=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/handlebars-template-1024x320.png\" alt=\"Handlebars template\" class=\"wp-image-13892\" srcset=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/handlebars-template-1024x320.png 1024w, https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/handlebars-template-300x94.png 300w, https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/handlebars-template-768x240.png 768w, https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/handlebars-template-1536x480.png 1536w, https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/handlebars-template.png 1852w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Generated html (left side) , Handlebars input (right side)<\/figcaption><\/figure><\/div>\n\n\n\n<p>In our rails app, on the home page load below AJAX call gets fired.<\/p>\n\n\n\n<p><script src=\"https:\/\/gist.github.com\/AnkurVyas-BTC\/9840f82423baa2a98fb5f7b5955cde27.js\"><\/script><\/p>\n\n\n\n<p>This call gets all the data of books in JSON format and pass it as context to&nbsp;<i><b>book_list<\/b><\/i> handlebars template. The html will be generated based on the data passed is stored in&nbsp;<i><b>bookListHtml<\/b><\/i>&nbsp;variable. Then it finds the div with the id named&nbsp;<i><b>book-list<\/b><\/i> and replace the html with newly generated handlebar html template. <\/p>\n\n\n\n<p>So handlebars makes it easy to generate views with JavaScript only. Add, edit and delete functionality has been also implemented using handlebars templates, you can find the source code at&nbsp;<a href=\"https:\/\/github.com\/AnkurVyas-BTC\/handlebar-rails\" target=\"_blank\" rel=\"noopener noreferrer\">handlebar-rails<\/a>. See below to have a look at what is implemented!<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"347\" src=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/handlebars.gif\" alt=\"handlebar js rails\" class=\"wp-image-13893\"\/><\/figure><\/div>\n\n\n\n<p>Handlebars also support&nbsp;<a href=\"https:\/\/github.com\/leshill\/handlebars_assets#hamlbars-and-slimbars-support\" target=\"_blank\" rel=\"noopener noreferrer\">haml and slim templates<\/a>&nbsp;do explore it!<\/p>\n\n\n\n<p>That&#8217;s it! Thanks for reading. If you liked it, press the lovely heart button&nbsp;\ud83d\ude42<\/p>\n\n\n\n<p><a href=\"https:\/\/www.botreetechnologies.com\/ruby-on-rails-development\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>Click here for more details&#8230;<\/strong><\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>At <a href=\"https:\/\/www.botreetechnologies.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">BoTree Technologies<\/a>, we build enterprise applications with our RoR team of 25+ engineers.<\/p>\n\n\n\n<p>We also specialize in RPA, AI, Python, Django, JavaScript and ReactJS.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/www.botreetechnologies.com\/contact\" target=\"_blank\" rel=\"noopener noreferrer\">Consulting is free<\/a> &#8211; let us help you grow!<\/h3>\n","protected":false},"excerpt":{"rendered":"<p>What is Handlebars.js? Handlebars&nbsp;allows to build semantic templates. Handlebars is&#8230;<\/p>\n","protected":false},"author":9,"featured_media":14510,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73,10],"tags":[],"class_list":["post-1795","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ruby-on-rails","category-technology"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Using Handlebars JS with Ruby on Rails!<\/title>\n<meta name=\"description\" content=\"What is Handlebars JS? Handlebars allows to build semantic templates. Handlebars is largely compatible with Mustache templates.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using Handlebars JS with Ruby on Rails!\" \/>\n<meta property=\"og:description\" content=\"What is Handlebars JS? Handlebars allows to build semantic templates. Handlebars is largely compatible with Mustache templates.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/\" \/>\n<meta property=\"og:site_name\" content=\"BoTree Technologies\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/BoTreeTechnologies\/\" \/>\n<meta property=\"article:published_time\" content=\"2017-03-14T09:48:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-08T12:08:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2017\/03\/handlebars-js-with-ruby-on-rails.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"852\" \/>\n\t<meta property=\"og:image:height\" content=\"479\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Ankur Vyas\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@BoTreeTech\" \/>\n<meta name=\"twitter:site\" content=\"@BoTreeTech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ankur Vyas\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/\"},\"author\":{\"name\":\"Ankur Vyas\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/aa180b4d8d933949f15aba97d8d138a5\"},\"headline\":\"Using Handlebars JS with Ruby on Rails!\",\"datePublished\":\"2017-03-14T09:48:19+00:00\",\"dateModified\":\"2021-09-08T12:08:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/\"},\"wordCount\":684,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2017\/03\/handlebars-js-with-ruby-on-rails.jpg\",\"articleSection\":[\"Ruby on Rails\",\"Technology\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/\",\"name\":\"Using Handlebars JS with Ruby on Rails!\",\"isPartOf\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2017\/03\/handlebars-js-with-ruby-on-rails.jpg\",\"datePublished\":\"2017-03-14T09:48:19+00:00\",\"dateModified\":\"2021-09-08T12:08:06+00:00\",\"author\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/aa180b4d8d933949f15aba97d8d138a5\"},\"description\":\"What is Handlebars JS? Handlebars allows to build semantic templates. Handlebars is largely compatible with Mustache templates.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/#primaryimage\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2017\/03\/handlebars-js-with-ruby-on-rails.jpg\",\"contentUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2017\/03\/handlebars-js-with-ruby-on-rails.jpg\",\"width\":852,\"height\":479,\"caption\":\"Handlebars JS with Ruby on Rails!\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.botreetechnologies.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using Handlebars JS with Ruby on Rails!\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#website\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/\",\"name\":\"BoTree Technologies\",\"description\":\"Committed to inspire generation.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.botreetechnologies.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/aa180b4d8d933949f15aba97d8d138a5\",\"name\":\"Ankur Vyas\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/ankur-vyas-1-150x150.png\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/ankur-vyas-1-150x150.png\",\"contentUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/ankur-vyas-1-150x150.png\",\"caption\":\"Ankur Vyas\"},\"description\":\"Ankur is a Ruby on Rails Developer and Practice Lead JavaScript. He loves Ruby, JavaScript, reading and writing blogs, problem-solving and taking ownership of work. Apart from coding he likes to listen to songs, gaming and traveling.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using Handlebars JS with Ruby on Rails!","description":"What is Handlebars JS? Handlebars allows to build semantic templates. Handlebars is largely compatible with Mustache templates.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/","og_locale":"en_US","og_type":"article","og_title":"Using Handlebars JS with Ruby on Rails!","og_description":"What is Handlebars JS? Handlebars allows to build semantic templates. Handlebars is largely compatible with Mustache templates.","og_url":"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/","og_site_name":"BoTree Technologies","article_publisher":"https:\/\/www.facebook.com\/BoTreeTechnologies\/","article_published_time":"2017-03-14T09:48:19+00:00","article_modified_time":"2021-09-08T12:08:06+00:00","og_image":[{"width":852,"height":479,"url":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2017\/03\/handlebars-js-with-ruby-on-rails.jpg","type":"image\/jpeg"}],"author":"Ankur Vyas","twitter_card":"summary_large_image","twitter_creator":"@BoTreeTech","twitter_site":"@BoTreeTech","twitter_misc":{"Written by":"Ankur Vyas","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/#article","isPartOf":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/"},"author":{"name":"Ankur Vyas","@id":"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/aa180b4d8d933949f15aba97d8d138a5"},"headline":"Using Handlebars JS with Ruby on Rails!","datePublished":"2017-03-14T09:48:19+00:00","dateModified":"2021-09-08T12:08:06+00:00","mainEntityOfPage":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/"},"wordCount":684,"commentCount":0,"image":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/#primaryimage"},"thumbnailUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2017\/03\/handlebars-js-with-ruby-on-rails.jpg","articleSection":["Ruby on Rails","Technology"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/","url":"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/","name":"Using Handlebars JS with Ruby on Rails!","isPartOf":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/#primaryimage"},"image":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/#primaryimage"},"thumbnailUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2017\/03\/handlebars-js-with-ruby-on-rails.jpg","datePublished":"2017-03-14T09:48:19+00:00","dateModified":"2021-09-08T12:08:06+00:00","author":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/aa180b4d8d933949f15aba97d8d138a5"},"description":"What is Handlebars JS? Handlebars allows to build semantic templates. Handlebars is largely compatible with Mustache templates.","breadcrumb":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/#primaryimage","url":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2017\/03\/handlebars-js-with-ruby-on-rails.jpg","contentUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2017\/03\/handlebars-js-with-ruby-on-rails.jpg","width":852,"height":479,"caption":"Handlebars JS with Ruby on Rails!"},{"@type":"BreadcrumbList","@id":"https:\/\/www.botreetechnologies.com\/blog\/using-handlebars-js-with-ruby-on-rails\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.botreetechnologies.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Using Handlebars JS with Ruby on Rails!"}]},{"@type":"WebSite","@id":"https:\/\/www.botreetechnologies.com\/blog\/#website","url":"https:\/\/www.botreetechnologies.com\/blog\/","name":"BoTree Technologies","description":"Committed to inspire generation.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.botreetechnologies.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/aa180b4d8d933949f15aba97d8d138a5","name":"Ankur Vyas","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/ankur-vyas-1-150x150.png","url":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/ankur-vyas-1-150x150.png","contentUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/ankur-vyas-1-150x150.png","caption":"Ankur Vyas"},"description":"Ankur is a Ruby on Rails Developer and Practice Lead JavaScript. He loves Ruby, JavaScript, reading and writing blogs, problem-solving and taking ownership of work. Apart from coding he likes to listen to songs, gaming and traveling."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/1795","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/comments?post=1795"}],"version-history":[{"count":3,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/1795\/revisions"}],"predecessor-version":[{"id":16225,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/1795\/revisions\/16225"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/media\/14510"}],"wp:attachment":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=1795"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=1795"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=1795"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}