{"id":18728741,"url":"https://github.com/rubyonworld/haml-js","last_synced_at":"2026-04-25T21:32:09.619Z","repository":{"id":174007928,"uuid":"542162510","full_name":"RubyOnWorld/haml-js","owner":"RubyOnWorld","description":"Precompiles the HAML-JS templates into a function.","archived":false,"fork":false,"pushed_at":"2022-09-28T00:57:26.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-19T20:32:43.578Z","etag":null,"topics":["function","html","js","precompile","template"],"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":"HISTORY.md","contributing":null,"funding":null,"license":"MIT-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:05.000Z","updated_at":"2022-09-28T03:13:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"bd87817d-50dd-4aa0-b6cf-b401c0be55d9","html_url":"https://github.com/RubyOnWorld/haml-js","commit_stats":null,"previous_names":["rubyonworld/haml-js"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RubyOnWorld/haml-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2Fhaml-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2Fhaml-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2Fhaml-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2Fhaml-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RubyOnWorld","download_url":"https://codeload.github.com/RubyOnWorld/haml-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2Fhaml-js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32278249,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T18:29:39.964Z","status":"ssl_error","status_checked_at":"2026-04-25T18:29:32.149Z","response_time":59,"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":["function","html","js","precompile","template"],"created_at":"2024-11-07T14:24:12.473Z","updated_at":"2026-04-25T21:32:09.602Z","avatar_url":"https://github.com/RubyOnWorld.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ruby HAML-JS\n\nPrecompiles the HAML-JS templates into a function.\n\nThis can be used as a standalone template or as part of Rails 3.1 assets pipeline.\n\nFor example, if you have a file `app/assets/javascripts/templates/comment.jst.hamljs` with the following content:\n\n```haml\n.comment\n  .author= author\n  .text= text\n```\n\nThen it will be *compiled* on the server side into a plain JavaScript function.\nIt doesn't require you to do anything on the client side.\nAnd the result will look like this:\n\n```javascript\n(function() {\n  this.JST || (this.JST = {});\n  this.JST[\"templates/comment\"] = function (locals) { function html_escape(text) {\n      return (text + \"\").\n        replace(/\u0026/g, \"\u0026amp;\").\n        replace(/\u003c/g, \"\u0026lt;\").\n        replace(/\u003e/g, \"\u0026gt;\").\n        replace(/\\\"/g, \"\u0026quot;\");\n    }\n  with(locals || {}) {\n    try {\n     var _$output=\"\u003cdiv class=\\\"comment\\\"\u003e\u003cdiv class=\\\"author\\\"\u003e\" + \n  html_escape(author) + \n  \"\u003c/div\u003e\u003cdiv class=\\\"text\\\"\u003e\" + \n  html_escape(text) + \n  \"\u003c/div\u003e\u003c/div\u003e\";\n   return _$output;  } catch (e) {\n      return \"\\n\u003cpre class='error'\u003e\" + html_escape(e.stack) + \"\u003c/pre\u003e\\n\";\n    }\n  }\n  };\n}).call(this);\n```\n\nThen you access that template like so:\n\n```javascript\nvar commentView = JST['templates/comment'];\n// ...\n// Somewhere in your code later:\nvar html = commentView({author: 'Dima', text: 'Looks nice'});\n```\n\n# Installation\n\n```ruby\n# Gemfile\ngem 'ruby-haml-js'\n```\n\n```bash\n# Then install it\nbundle\n```\n\n# Usage - with Rails 3.1 assets pipeline\n\n1. Put your template unders `app/assets/javascripts` (or other path where Rails can find it).\n2. Use the naming `my-template.jst.hamljs`.\n3. Serve the template to browser by `require my-template` from `application.js` or link to it as `my-template.js`\n4. Use the template from the JavaScript: `JST['my-template']({your: 'local', variables: 'go here'})`\n\n\n# Configuration\n\n## Custom HTML escape\n\nYou can change the escape function from the built-in, autogenerated to your own:\n\n```ruby\n# Set it somewhere, before generating the template.\n# Good place can be a Rails initializer.\nRubyHamlJs::Template.custom_escape = \"App.escape_html\"\n```\n\nThis will use the given function and will not generate custom escape code inside each template.\nBut you need to make sure that the function is defined before using the templates in JavaScript.\n\n## Custom haml.js\n\nIf you need a custom version of haml.js library you may specify it using the haml_path\n\n```ruby\nRubyHamlJs::Template.haml_path = \"path/to/haml.js\"\n```\n\n# Development\n\n- Source hosted at [GitHub](https://github.com/dnagir/ruby-haml-js)\n- Report issues and feature requests to [GitHub Issues](https://github.com/dnagir/ruby-haml-js/issues)\n\nPull requests are very welcome! But please write the specs.\n\nTo start, clone the repo and then:\n\n```shell\nbundle install\nbundle exec rspec spec/\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyonworld%2Fhaml-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubyonworld%2Fhaml-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyonworld%2Fhaml-js/lists"}