{"id":15022256,"url":"https://github.com/jonschlinkert/load-helpers","last_synced_at":"2025-04-12T06:16:12.588Z","repository":{"id":60775080,"uuid":"42306348","full_name":"jonschlinkert/load-helpers","owner":"jonschlinkert","description":"easily load helpers to pass to any template engine.","archived":false,"fork":false,"pushed_at":"2017-04-20T06:05:54.000Z","size":35,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T06:16:04.031Z","etag":null,"topics":["glob","handlebars-helpers","helpers","load","template-engine"],"latest_commit_sha":null,"homepage":null,"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":"2015-09-11T12:09:11.000Z","updated_at":"2024-02-10T16:57:59.000Z","dependencies_parsed_at":"2022-10-04T16:16:42.499Z","dependency_job_id":null,"html_url":"https://github.com/jonschlinkert/load-helpers","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%2Fload-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fload-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fload-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fload-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/load-helpers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248525139,"owners_count":21118620,"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":["glob","handlebars-helpers","helpers","load","template-engine"],"created_at":"2024-09-24T19:57:42.460Z","updated_at":"2025-04-12T06:16:12.564Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# load-helpers [![NPM version](https://img.shields.io/npm/v/load-helpers.svg?style=flat)](https://www.npmjs.com/package/load-helpers) [![NPM monthly downloads](https://img.shields.io/npm/dm/load-helpers.svg?style=flat)](https://npmjs.org/package/load-helpers)  [![NPM total downloads](https://img.shields.io/npm/dt/load-helpers.svg?style=flat)](https://npmjs.org/package/load-helpers) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/load-helpers.svg?style=flat\u0026label=Travis)](https://travis-ci.org/jonschlinkert/load-helpers)\n\n\u003e Load helpers with patterns, as an object, key-value pair, or module.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save load-helpers\n```\n\nInstall with [yarn](https://yarnpkg.com):\n\n```sh\n$ yarn add load-helpers\n```\n\n## API\n\n### [Loader](index.js#L24)\n\nCreate an instance of `Loader` with the given `options`.\n\n**Params**\n\n* `options` **{Object}**\n\n**Example**\n\n```js\nvar Loader = require('load-helpers');\nvar loader = new Loader();\n```\n\n### [.addHelper](index.js#L53)\n\nRegister a helper function by `name`.\n\n**Params**\n\n* `name` **{String}**\n* `fn` **{Function}**\n* `options` **{Object}**\n\n**Example**\n\n```js\nloader.addHelper('foo', function() {\n  // do stuff\n});\n```\n\n### [.addHelpers](index.js#L89)\n\nRegister an object of helper functions.\n\n**Params**\n\n* `helpers` **{Object}**\n* `options` **{Object}**\n\n**Example**\n\n```js\nloader.addHelpers({\n  foo: function() {},\n  bar: function() {},\n  baz: function() {}\n});\n```\n\n### [.load](index.js#L116)\n\nLoad one or more helpers from a filepath, glob pattern, object, or an array of any of those things. This method detects the type of value to be handled then calls one of the other methods to do the actual loading.\n\n**Params**\n\n* `helpers` **{Object}**\n* `options` **{Object}**\n* `returns` **{Object}**: Returns the views from `loader.helpers`\n\n**Example**\n\n```js\nvar loader = new Loader();\nconsole.log(loader.load(['foo/*.hbs', 'bar/*.hbs']));\nconsole.log(loader.load({path: 'a/b/c.md'}));\nconsole.log(loader.load('index', {path: 'a/b/c.md'}));\n```\n\n## options.renameHelper\n\nCustomize how dynamically-added helpers are named as they're loaded.\n\n**Examples**\n\nPass a custom `renameHelper` function on the ctor.\n\n```js\nvar loader = new Loader({\n  renameHelper: function(key) {\n    // simple camel-case\n    return key.replace(/\\W(.)/g, function(_, ch) {\n      return ch.toUpperCase();\n    });\n  }\n});\n\nloader.load('for-own');\nconsole.log(loader.helpers);\n// { 'forOwn': [Function: forOwn] }\n```\n\nOr to only renamed specific helpers, you can pass the `renameHelper` function to any of the methods.\n\n```js\nloader.load('for-own', {\n  renameHelper: function(key) {\n    // simple camel-case\n    return key.replace(/\\W(.)/g, function(_, ch) {\n      return ch.toUpperCase();\n    });\n  }\n});\nconsole.log(loader.helpers);\n// { 'forOwn': [Function: forOwn] }\n```\n\n## About\n\n### Related projects\n\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* [helper-cache](https://www.npmjs.com/package/helper-cache): Easily register and get helper functions to be passed to any template engine or node.js… [more](https://github.com/jonschlinkert/helper-cache) | [homepage](https://github.com/jonschlinkert/helper-cache \"Easily register and get helper functions to be passed to any template engine or node.js application. Methods for both sync and async helpers.\")\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### Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n### Contributors\n\n| **Commits** | **Contributor** | \n| --- | --- |\n| 39 | [jonschlinkert](https://github.com/jonschlinkert) |\n| 3 | [doowb](https://github.com/doowb) |\n\n### Building docs\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### Running tests\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### Author\n\n**Jon Schlinkert**\n\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2017, [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.5.0, on April 20, 2017._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fload-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Fload-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fload-helpers/lists"}