{"id":15105175,"url":"https://github.com/patocallaghan/broccoli-handlebars-precompiler-esm","last_synced_at":"2025-09-27T03:30:32.844Z","repository":{"id":43887021,"uuid":"458219750","full_name":"patocallaghan/broccoli-handlebars-precompiler-esm","owner":"patocallaghan","description":"Precompiles Handlebars templates into ECMAScript Modules","archived":false,"fork":true,"pushed_at":"2022-02-14T11:02:33.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-17T14:36:17.756Z","etag":null,"topics":["broccoli","broccoli-plugin","ember","handlebars"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"jakkor/broccoli-handlebars-precompiler","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/patocallaghan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-11T14:29:51.000Z","updated_at":"2023-09-08T18:31:38.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/patocallaghan/broccoli-handlebars-precompiler-esm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/patocallaghan/broccoli-handlebars-precompiler-esm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patocallaghan%2Fbroccoli-handlebars-precompiler-esm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patocallaghan%2Fbroccoli-handlebars-precompiler-esm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patocallaghan%2Fbroccoli-handlebars-precompiler-esm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patocallaghan%2Fbroccoli-handlebars-precompiler-esm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patocallaghan","download_url":"https://codeload.github.com/patocallaghan/broccoli-handlebars-precompiler-esm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patocallaghan%2Fbroccoli-handlebars-precompiler-esm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277177867,"owners_count":25774349,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-27T02:00:08.978Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["broccoli","broccoli-plugin","ember","handlebars"],"created_at":"2024-09-25T20:21:38.152Z","updated_at":"2025-09-27T03:30:32.536Z","avatar_url":"https://github.com/patocallaghan.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Broccoli Handlebars Precompiler ESM\n\n**Disclaimer:** This repo is a fork of the great [jakkor/broccoli-handlebars-precompiler](https://www.github.com/jakkor/broccoli-handlebars-precompiler). The difference between implementations being that the original focused on only working with global JavaScript variables, whereas this version focuses on working with more modern JavaScript standards, i.e. ECMAScript Modules (ESM).\n\n---\n\nA [Broccoli](https://github.com/broccolijs/broccoli) plugin that gives us an easy way to precompile [Handlebars](http://handlebarsjs.com/) templates into [ECMAScript Modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules), aka ESM.\n\nIt works by taking each input Handlebars file, precompiles it using [`Handlebars.precompile`](https://handlebarsjs.com/installation/precompilation.html#precompiling-templates-inside-nodejs) and outputs a JS file (by default) that can be later combined by a different tool.\n\n## Install\n```\nnpm install --save broccoli-handlebars-precompiler-esm\n\nyarn add broccoli-handlebars-precompiler-esm\n```\n\n## Usage\n```js\nconst BroccoliHandlebars = require('broccoli-handlebars-precompiler-esm');\n\n// ...\nlet precompiledTemplates = new BroccoliHandlebars(templates, {\n  extensions: ['handlebars'],\n});\n\n```\n\n## API\n\n```js\nconst precompiledTemplates = new BroccoliHandlebars(inputNodes, options);\n```\n\n* `inputNodes`: An array of node objects that this plugin will read from. Nodes are usually other plugin instances; they were formerly known as \"trees\".\n\n### Options\n* `annotation` (optional): Same as [broccoli-plugin](https://github.com/broccolijs/broccoli-plugin#new-plugininputnodes-options); see there.\n* `extensions` (optional): Array of handlebars file extensions. Default: `['hbs', 'handlebars']`.\n* `targetExtension` (optional): The file extension of the corresponding output files. Default: `js`.\n\n## How to use it in JavaScript application\n\n### Input\n`my-handlebars-template.hbs`\n```hbs\n\u003cdiv class=\"my-class\"\u003e\u003c/div\u003e\n```\n\n### Output\n`my-handlebars-template.js`\n```js\nimport Handlebars from 'handlebars';\n\nconst _template = Handlebars.template({\n  \"compiler\": [8, \"\u003e= 4.3.0\"],\n  \"main\": function (container, depth0, helpers, partials, data) {\n    return \"\u003cdiv class=\\\"my-class\\\"\u003e\u003c/div\u003e\\n\";\n  },\n  \"useData\": true\n});\n\nexport default _template;\n```\n\n### Using the template\nYou must have a copy of the Handlebars runtime available in your application. See the [Handlebars docs](https://handlebarsjs.com/installation/#installation) for more information how to install it.\n\nTo use in your app you then import the template and invoke it passing any data it needs. See [Handlebars docs](https://handlebarsjs.com/api-reference/compilation.html#handlebars-template-templatespec) for more details.\n\n```js\nimport myHandlebarsTemplate from './my-handlebars-template.js';\nmyHandlebarsTemplate(data)\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatocallaghan%2Fbroccoli-handlebars-precompiler-esm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatocallaghan%2Fbroccoli-handlebars-precompiler-esm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatocallaghan%2Fbroccoli-handlebars-precompiler-esm/lists"}