{"id":15809276,"url":"https://github.com/nknapp/handlebars-source-locators","last_synced_at":"2026-04-11T21:42:46.407Z","repository":{"id":57260575,"uuid":"84754826","full_name":"nknapp/handlebars-source-locators","owner":"nknapp","description":"Puts source-position markers into the Handlebars output","archived":false,"fork":false,"pushed_at":"2017-03-16T20:13:09.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-19T06:49:13.577Z","etag":null,"topics":["handlebars","source-maps"],"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/nknapp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-12T20:24:00.000Z","updated_at":"2017-03-13T11:02:42.000Z","dependencies_parsed_at":"2022-08-25T06:01:44.562Z","dependency_job_id":null,"html_url":"https://github.com/nknapp/handlebars-source-locators","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/nknapp/handlebars-source-locators","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nknapp%2Fhandlebars-source-locators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nknapp%2Fhandlebars-source-locators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nknapp%2Fhandlebars-source-locators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nknapp%2Fhandlebars-source-locators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nknapp","download_url":"https://codeload.github.com/nknapp/handlebars-source-locators/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nknapp%2Fhandlebars-source-locators/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266076350,"owners_count":23872741,"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":["handlebars","source-maps"],"created_at":"2024-10-05T03:21:13.167Z","updated_at":"2026-04-11T21:42:41.336Z","avatar_url":"https://github.com/nknapp.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# handlebars-source-locators \n\n[![NPM version](https://badge.fury.io/js/handlebars-source-locators.svg)](http://badge.fury.io/js/handlebars-source-locators)\n[![Travis Build Status](https://travis-ci.org/nknapp/handlebars-source-locators.svg?branch=master)](https://travis-ci.org/nknapp/handlebars-source-locators)\n[![Coverage Status](https://img.shields.io/coveralls/nknapp/handlebars-source-locators.svg)](https://coveralls.io/r/nknapp/handlebars-source-locators)\n\n\n\u003e Puts source-position markers into the Handlebars output\n\n\n# Installation\n\n```\nnpm install handlebars-source-locators\n```\n\n \n## Usage\n\nThe following example demonstrates how to use this module:\n\n```js\nconst Handlebars = require('handlebars')\nconst addSourceLocators = require('handlebars-source-locators')\n\n// Create a new Handlebars environment and add source-locators\nconst hbs = addSourceLocators(Handlebars.create())\n\nhbs.registerPartial('info', `\nName: {{name}}\nCity: {{city}}\n`)\n\nhbs.registerPartial('hobbies', `\n{{#each hobbies}}\n- {{.}}\n{{/each}}\n`)\n\nconst template = hbs.compile(`\nInfo:\n-----\n{{\u003e info}}\n\nHobbies:\n-----\n{{\u003e hobbies}}\n`)\n\nconsole.log(template({\n  name: 'Nils Knappmeier',\n  city: 'Darmstadt',\n  hobbies: [\n    'Aikido',\n    'Programming',\n    'Theater',\n    'Music'\n  ]\n}))\n```\n\nThis will generate the following output\n\n```\n\u003csl line=\"1\" col=\"0\"\u003e\u003c/sl\u003e\nInfo:\n-----\n\u003csl line=\"4\" col=\"0\"\u003e\u003c/sl\u003e\u003csl line=\"1\" col=\"0\" partial=\"info\"\u003e\u003c/sl\u003e\nName: \u003csl line=\"2\" col=\"6\" partial=\"info\"\u003e\u003c/sl\u003eNils Knappmeier\u003csl line=\"2\" col=\"14\" partial=\"info\"\u003e\u003c/sl\u003e\nCity: \u003csl line=\"3\" col=\"6\" partial=\"info\"\u003e\u003c/sl\u003eDarmstadt\u003csl line=\"3\" col=\"14\" partial=\"info\"\u003e\u003c/sl\u003e\n\u003csl line=\"4\" col=\"0\" partial=\"info\"\u003e\u003c/sl\u003e\u003csl line=\"4\" col=\"10\"\u003e\u003c/sl\u003e\nHobbies:\n-----\n\u003csl line=\"8\" col=\"0\"\u003e\u003c/sl\u003e\u003csl line=\"1\" col=\"0\" partial=\"hobbies\"\u003e\u003c/sl\u003e\n\u003csl line=\"2\" col=\"0\" partial=\"hobbies\"\u003e\u003c/sl\u003e\u003csl line=\"2\" col=\"17\" partial=\"hobbies\"\u003e\u003c/sl\u003e- \u003csl line=\"3\" col=\"2\" partial=\"hobbies\"\u003e\u003c/sl\u003eAikido\u003csl line=\"3\" col=\"7\" partial=\"hobbies\"\u003e\u003c/sl\u003e\n\u003csl line=\"4\" col=\"0\" partial=\"hobbies\"\u003e\u003c/sl\u003e\u003csl line=\"2\" col=\"17\" partial=\"hobbies\"\u003e\u003c/sl\u003e- \u003csl line=\"3\" col=\"2\" partial=\"hobbies\"\u003e\u003c/sl\u003eProgramming\u003csl line=\"3\" col=\"7\" partial=\"hobbies\"\u003e\u003c/sl\u003e\n\u003csl line=\"4\" col=\"0\" partial=\"hobbies\"\u003e\u003c/sl\u003e\u003csl line=\"2\" col=\"17\" partial=\"hobbies\"\u003e\u003c/sl\u003e- \u003csl line=\"3\" col=\"2\" partial=\"hobbies\"\u003e\u003c/sl\u003eTheater\u003csl line=\"3\" col=\"7\" partial=\"hobbies\"\u003e\u003c/sl\u003e\n\u003csl line=\"4\" col=\"0\" partial=\"hobbies\"\u003e\u003c/sl\u003e\u003csl line=\"2\" col=\"17\" partial=\"hobbies\"\u003e\u003c/sl\u003e- \u003csl line=\"3\" col=\"2\" partial=\"hobbies\"\u003e\u003c/sl\u003eMusic\u003csl line=\"3\" col=\"7\" partial=\"hobbies\"\u003e\u003c/sl\u003e\n\u003csl line=\"4\" col=\"0\" partial=\"hobbies\"\u003e\u003c/sl\u003e\n```\n\n##  API-reference\n\n\u003ca name=\"addSourceLocators\"\u003e\u003c/a\u003e\n\n## addSourceLocators(handlebarsEnvironment)\nAdds source-locators to a Handlebars-environment. The template-output\nwill include tags of the form `\u003csl line=\"1\" col=\"4\" [partial=\"partialName\"]\u003e`\n\nThe meaning is that the output directly after this tag originates from the\nline/column in the tag. If the \"partial\" is not set, the output originates from the\nmain-template.\n\nThe \"line\"-property is based off 1. The \"col\"-property is based off 0.\nThis is consistent with the output of the \"Handlebars.parse()\"-function.\n\n**Kind**: global function  \n**Throws**:\n\n- Error if `handlebarsEnvironment` is the default Handlebars-environment.\n  Please use \"Handlebars.create\" to create a new environment and pass that to this function.\n  The default instance may be used in many places of the dependency tree. Modifying it may\n  cause unexpected behavior in other libraries that seem not connected to this one at all.\n\n**Access:** public  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| handlebarsEnvironment | \u003ccode\u003eHandlebars\u003c/code\u003e | the Handlebars environment to modify |\n\n\n\n\n## License\n\n`handlebars-source-locators` is published under the MIT-license. \nSee [LICENSE.md](LICENSE.md) for details.\n\n## Release-Notes\n \nFor release notes, see [CHANGELOG.md](CHANGELOG.md)\n \n## Contributing guidelines\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnknapp%2Fhandlebars-source-locators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnknapp%2Fhandlebars-source-locators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnknapp%2Fhandlebars-source-locators/lists"}