{"id":18728743,"url":"https://github.com/rubyonworld/handlebars","last_synced_at":"2026-04-24T20:36:43.263Z","repository":{"id":174007931,"uuid":"542162559","full_name":"RubyOnWorld/handlebars","owner":"RubyOnWorld","description":"Pure Ruby library for Handlebars template system. The main goal of this library is to simplify the use of Ruby and Handlebars on Windows machine.","archived":false,"fork":false,"pushed_at":"2022-09-28T01:06:58.000Z","size":131,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-11T19:19:05.425Z","etag":null,"topics":["handlebars","library","ruby","system"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RubyOnWorld.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-27T15:39:12.000Z","updated_at":"2022-09-28T04:00:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"963caa90-16c8-4f15-9e4b-daebc83d44d5","html_url":"https://github.com/RubyOnWorld/handlebars","commit_stats":null,"previous_names":["rubyonworld/handlebars"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RubyOnWorld/handlebars","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2Fhandlebars","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2Fhandlebars/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2Fhandlebars/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2Fhandlebars/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RubyOnWorld","download_url":"https://codeload.github.com/RubyOnWorld/handlebars/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2Fhandlebars/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32240200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T13:21:15.438Z","status":"ssl_error","status_checked_at":"2026-04-24T13:21:15.005Z","response_time":64,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["handlebars","library","ruby","system"],"created_at":"2024-11-07T14:24:12.848Z","updated_at":"2026-04-24T20:36:43.248Z","avatar_url":"https://github.com/RubyOnWorld.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"ruby-handlebars\n===============\n\n[![Build status](https://github.com/SmartBear/ruby-handlebars/actions/workflows/ci.yml/badge.svg)](https://github.com/SmartBear/ruby-handlebars/actions/workflows/ci.yml)\n[![Maintainability](https://api.codeclimate.com/v1/badges/22dbe81de487cb27097c/maintainability)](https://codeclimate.com/github/SmartBear/ruby-handlebars/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/22dbe81de487cb27097c/test_coverage)](https://codeclimate.com/github/SmartBear/ruby-handlebars/test_coverage)\n\nPure Ruby library for [Handlebars](http://handlebarsjs.com/) template system.\nThe main goal of this library is to simplify the use of Ruby and Handlebars on Windows machine. If you do not have any need of working on Windows, take a look at [handlebars.rb](https://github.com/cowboyd/handlebars.rb) that uses the real Handlebars library.\n\nInstalling\n----------\n\nSimply run:\n\n```shell\ngem install ruby-handlebars\n```\n\nNo need for libv8, ruby-racer or any JS related tool.\n\nUsing\n-----\n\nA very simple case:\n\n```ruby\n\nrequire 'ruby-handlebars'\n\nhbs = Handlebars::Handlebars.new\nhbs.compile(\"Hello {{name}}\").call({name: 'world'})\n# Gives: \"Hello world\", how original ...\n```\n\nYou can also use partials:\n\n```ruby\nhbs.register_partial('full_name', \"{{person.first_name}} {{person.last_name}}\")\nhbs.compile(\"Hello {{\u003e full_name}}\").call({person: {first_name: 'Pinkie', last_name: 'Pie'}})\n# Gives: \"Hello Pinkie Pie\"\n```\n\nPartials support parameters:\n```ruby\nhbs.register_partial('full_name', \"{{fname}} {{lname}}\")\nhbs.compile(\"Hello {{\u003e full_name fname='jon' lname='doe'}}\")\n# Gives: \"Hello jon doe\"\n```\n\nYou can also register inline helpers:\n\n```ruby\nhbs.register_helper('strip') {|context, value| value.strip}\nhbs.compile(\"Hello {{strip name}}\").call({name: '                       world     '})\n# Will give (again ....): \"Hello world\"\n```\n\nor block helpers:\n\n```ruby\nhbs.register_helper('comment') do |context, commenter, block|\n  block.fn(context).split(\"\\n\").map do |line|\n    \"#{commenter} #{line}\"\n  end.join(\"\\n\")\nend\n\nhbs.compile(\"{{#comment '//'}}My comment{{/comment}}\").call\n# Will give: \"// My comment\"\n```\n\nNote that in any block helper you can use an ``else`` block:\n\n```ruby\nhbs.register_helper('markdown') do |context, block, else_block|\n  html = md_to_html(block.fn(context))\n  html.nil? : else_block.fn(context) : html\nend\n\ntemplate = [\n  \"{{#markdown}}\",\n  \"  {{ description }}\",\n  \"{{else}}\",\n  \"  Description is not valid markdown, no preview available\",\n  \"{{/markdown}}\"\n].join(\"\\n\")\n\nhbs.compile(template).call({description: my_description})\n# Output will depend on the validity of the 'my_description' variable\n```\n\nDefault helpers:\n----------------\n\nThree default helpers are provided: ``each``, ``if`` and ``unless``.\n\nThe each helper let you walk through a list. You can either use the basic notation and referencing the current item as ``this``:\n\n```\n  {{#each items}}\n    {{{ this }}}\n  {{else}}\n    No items\n  {{/each}}\n```\n\nor the \"as |name|\" notation:\n\n```\n  {{#each items as |item| }}\n    {{{ item }}}\n  {{else}}\n    No items\n  {{/each}}\n```\n\nThe ``if`` helper can be used to write conditionnal templates:\n\n```\n  {{#if my_condition}}\n    It's ok\n  {{else}}\n    or maybe not\n  {{/if}}\n```\n\nThe ``unless`` helper works the opposite way to ``if``:\n\n```\n  {{#unless my_condition}}\n    It's not ok\n  {{else}}\n    or maybe it is\n  {{/unless}}\n```\n\nCurrently, if you call an unknown helper, it will raise an exception. You can override that by registering your own version of the ``helperMissing`` helper. Note that only the name of the missing helper will be provided.\n\nFor example:\n\n```ruby\nhbs.register_helper('helperMissing') do |context, name|\n  puts \"No helper found with name #{name}\"\nend\n```\n\nLimitations and roadmap\n-----------------------\n\nThis gem does not reuse the real Handlebars code (the JS one) and not everything is handled yet (but it will be someday ;) ):\n\n - the parser is not fully tested yet, it may complain with spaces ...\n - parsing errors are, well, not helpful at all\n\nAknowledgements\n---------------\n\nThis gem would simply not exist if the handlebars team was not here. Thanks a lot for this awesome templating system.\nThanks a lot to @cowboyd for the [handlebars.rb](https://github.com/cowboyd/handlebars.rb) gem. We used it for a while and it's great (and as told at the beginning of the README, if you do not need any Windows support, use handlebars.rb instead ;) )\n\nThanks a lot to the contributors @mvz, @schuetzm and @stewartmckee for making it a way better Handlebars renderer :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyonworld%2Fhandlebars","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubyonworld%2Fhandlebars","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyonworld%2Fhandlebars/lists"}