{"id":15046274,"url":"https://github.com/jonschlinkert/engine-handlebars","last_synced_at":"2025-10-26T14:31:35.397Z","repository":{"id":20454441,"uuid":"23731599","full_name":"jonschlinkert/engine-handlebars","owner":"jonschlinkert","description":"Handlebars engine, consolidate.js style but with enhancements. This works with Assemble, express.js, engine-cache or any application that follows consolidate.js conventions.","archived":false,"fork":false,"pushed_at":"2020-08-12T09:09:44.000Z","size":53,"stargazers_count":7,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-01T00:51:10.647Z","etag":null,"topics":["compile","engine","engine-handlebars","handlebars","hbs","helpers","javascript","jonschlinkert","node","nodejs","partial","render"],"latest_commit_sha":null,"homepage":"https://github.com/jonschlinkert","language":"JavaScript","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/jonschlinkert.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":"2014-09-06T09:47:42.000Z","updated_at":"2024-01-26T12:54:23.000Z","dependencies_parsed_at":"2022-09-11T01:10:14.112Z","dependency_job_id":null,"html_url":"https://github.com/jonschlinkert/engine-handlebars","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fengine-handlebars","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fengine-handlebars/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fengine-handlebars/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fengine-handlebars/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/engine-handlebars/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238347827,"owners_count":19457001,"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","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":["compile","engine","engine-handlebars","handlebars","hbs","helpers","javascript","jonschlinkert","node","nodejs","partial","render"],"created_at":"2024-09-24T20:52:56.437Z","updated_at":"2025-10-26T14:31:35.094Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","readme":"# engine-handlebars [![NPM version](https://img.shields.io/npm/v/engine-handlebars.svg?style=flat)](https://www.npmjs.com/package/engine-handlebars) [![NPM monthly downloads](https://img.shields.io/npm/dm/engine-handlebars.svg?style=flat)](https://npmjs.org/package/engine-handlebars) [![NPM total downloads](https://img.shields.io/npm/dt/engine-handlebars.svg?style=flat)](https://npmjs.org/package/engine-handlebars) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/engine-handlebars.svg?style=flat\u0026label=Travis)](https://travis-ci.org/jonschlinkert/engine-handlebars)\n\n\u003e Handlebars engine, consolidate.js style but with enhancements. This works with Assemble, express.js, engine-cache or any application that follows consolidate.js conventions.\n\nPlease consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save engine-handlebars\n```\n\n## Heads up!\n\nThere were major [breaking changes in v1.0!](#release-history).\n\n## Usage\n\n```js\nconst handlebars = require('handlebars');\nconst engine = require('engine-handlebars')(handlebars);\nconsole.log(engine);\n```\n\nThe `engine` object that is returned has the following properties:\n\n* `name` - the name of the engine: `handlebars`, used for engine detection in other libraries.\n* `instance` - your instance of handlebars\n* `compile` - async compile method\n* `compileSync` - sync compile method\n* `render` -  async render method\n* `renderSync` - sync render method\n\n## API\n\n### [.compile](index.js#L49)\n\nCompile `file.contents` with `handlebars.compile()`. Adds a compiled `.fn()` property to the given `file`.\n\n**Params**\n\n* `file` **{Object}**: File object with `contents` string or buffer.\n* `options` **{Object}**: Options with partials and helpers.\n* `returns` **{Promise}**\n\n**Example**\n\n```js\nengine.compile({ contents: 'Jon {{ name }}' })\n  .then(file =\u003e {\n    console.log(typeof file.fn) // 'function'\n  });\n```\n\n### [.render](index.js#L70)\n\nRender `file.contents` with the function returned from `.compile()`.\n\n**Params**\n\n* `file` **{Object}**: File object with `contents` string or buffer.\n* `locals` **{Object}**: Locals to use as contents to render the string.\n* `options` **{Object}**: Options with partials and helpers.\n* `returns` **{Promise}**\n\n**Example**\n\n```js\nengine.render({ contents: 'Jon {{ name }}' }, { name: 'Schlinkert' })\n  .then(file =\u003e {\n    console.log(file.contents.toString()) // 'Jon Schlinkert'\n  });\n```\n\n### [.compileSync](index.js#L116)\n\nCompile `file.contents` with `handlebars.compile()`. Adds a compiled `.fn()` property to the given `file`.\n\n**Params**\n\n* `file` **{Object}**: File object with `contents` string or buffer.\n* `options` **{Object}**: Options with partials and helpers.\n* `returns` **{Object}**: Returns the file object.\n\n**Example**\n\n```js\nlet file = engine.compileSync({ contents: 'Jon {{ name }}' });\nconsole.log(typeof file.fn) // 'function'\n```\n\n### [.renderSync](index.js#L146)\n\nRender `file.contents` with the function returned from `.compile()`.\n\n**Params**\n\n* `file` **{Object}**: File object with `contents` string or buffer.\n* `locals` **{Object}**: Locals to use as contents to render the string.\n* `options` **{Object}**: Options with partials and helpers.\n* `returns` **{Object}**: Returns the file object.\n\n**Example**\n\n```js\nlet file = engine.renderSync({ contents: 'Jon {{ name }}' }, { name: 'Schlinkert' });\nconsole.log(file.contents.toString()) // 'Jon Schlinkert'\n```\n\n## Release History\n\n### v1.0.0\n\n* The main export is now a function that takes an instance of handlebars.\n* `renderFile` and `__express` have been removed.\n* `.compile` and `.render` now return a promise.\n* `.compileSync` and `.renderSync` may be used for sync operations.\n* All methods now expect a `file` object with a `.contents` property (string or buffer).\n\n### v0.8.0\n\n* `renderFile` now expects a [vinyl](https://github.com/gulpjs/vinyl) file.\n* The old renderFile method is now exposed on `engine.__express`\n\n### v0.7.0\n\n* updated to handlebars 0.4.0\n\n## About\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eContributing\u003c/strong\u003e\u003c/summary\u003e\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eRunning Tests\u003c/strong\u003e\u003c/summary\u003e\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eBuilding docs\u003c/strong\u003e\u003c/summary\u003e\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n\u003c/details\u003e\n\n### Related projects\n\nYou might also be interested in these projects:\n\n* [assemble](https://www.npmjs.com/package/assemble): Get the rocks out of your socks! Assemble makes you fast at creating web projects… [more](https://github.com/assemble/assemble) | [homepage](https://github.com/assemble/assemble \"Get the rocks out of your socks! Assemble makes you fast at creating web projects. Assemble is used by thousands of projects for rapid prototyping, creating themes, scaffolds, boilerplates, e-books, UI components, API documentation, blogs, building websit\")\n* [handlebars-helpers](https://www.npmjs.com/package/handlebars-helpers): More than 130 Handlebars helpers in ~20 categories. Helpers can be used with Assemble, Generate… [more](https://github.com/helpers/handlebars-helpers) | [homepage](https://github.com/helpers/handlebars-helpers \"More than 130 Handlebars helpers in ~20 categories. Helpers can be used with Assemble, Generate, Verb, Ghost, gulp-handlebars, grunt-handlebars, consolidate, or any node.js/Handlebars project.\")\n* [template-helpers](https://www.npmjs.com/package/template-helpers): Generic JavaScript helpers that can be used with any template engine. Handlebars, Lo-Dash, Underscore, or… [more](https://github.com/jonschlinkert/template-helpers) | [homepage](https://github.com/jonschlinkert/template-helpers \"Generic JavaScript helpers that can be used with any template engine. Handlebars, Lo-Dash, Underscore, or any engine that supports helper functions.\")\n* [templates](https://www.npmjs.com/package/templates): System for creating and managing template collections, and rendering templates with any node.js template engine… [more](https://github.com/jonschlinkert/templates) | [homepage](https://github.com/jonschlinkert/templates \"System for creating and managing template collections, and rendering templates with any node.js template engine. Can be used as the basis for creating a static site generator or blog framework.\")\n\n### Contributors\n\n| **Commits** | **Contributor** |  \n| --- | --- |  \n| 32 | [jonschlinkert](https://github.com/jonschlinkert) |  \n| 18 | [doowb](https://github.com/doowb) |  \n\n### Author\n\n**Jon Schlinkert**\n\n* [GitHub Profile](https://github.com/jonschlinkert)\n* [Twitter Profile](https://twitter.com/jonschlinkert)\n* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)\n\n### License\n\nCopyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on November 11, 2018._","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fengine-handlebars","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Fengine-handlebars","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fengine-handlebars/lists"}