{"id":15757049,"url":"https://github.com/azu/lodash-template-js-parser","last_synced_at":"2025-08-02T17:10:31.268Z","repository":{"id":66143459,"uuid":"217509547","full_name":"azu/lodash-template-js-parser","owner":"azu","description":"A JavaScript parser for `lodash.template`.","archived":false,"fork":false,"pushed_at":"2019-10-30T07:10:11.000Z","size":62,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-23T23:48:55.138Z","etag":null,"topics":["javascript","lodash","parser","splitter","template"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/azu.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"azu"}},"created_at":"2019-10-25T10:25:01.000Z","updated_at":"2023-12-05T06:33:54.000Z","dependencies_parsed_at":"2023-04-30T17:08:15.904Z","dependency_job_id":null,"html_url":"https://github.com/azu/lodash-template-js-parser","commit_stats":{"total_commits":14,"total_committers":1,"mean_commits":14.0,"dds":0.0,"last_synced_commit":"911c13743f2434e686a53d18fc29ee92803f85f6"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/azu/lodash-template-js-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azu%2Flodash-template-js-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azu%2Flodash-template-js-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azu%2Flodash-template-js-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azu%2Flodash-template-js-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/azu","download_url":"https://codeload.github.com/azu/lodash-template-js-parser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azu%2Flodash-template-js-parser/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268340711,"owners_count":24234806,"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-08-02T02:00:12.353Z","response_time":74,"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":["javascript","lodash","parser","splitter","template"],"created_at":"2024-10-04T09:03:59.734Z","updated_at":"2025-08-02T17:10:31.259Z","avatar_url":"https://github.com/azu.png","language":"TypeScript","funding_links":["https://github.com/sponsors/azu"],"categories":[],"sub_categories":[],"readme":"# lodash-template-js-parser [![Build Status](https://travis-ci.org/azu/lodash-template-js-parser.svg?branch=master)](https://travis-ci.org/azu/lodash-template-js-parser)\n\nA JavaScript parser/splitter for [`lodash.template`](https://lodash.com/docs/#template)\n\n## Features\n\n- It separate JavaScript Code and Template String from `lodash.template` content\n    - Preserve same position of JavaScript code as possible\n\n\u003e Lodash template -\u003e JavaScript Code and Template Content.\n\nIt help to implement lint tools for JavaScript code in lodash template.\n\nThis idea and implementation is based on [ota-meshi/eslint-plugin-lodash-template](https://github.com/ota-meshi/eslint-plugin-lodash-template).\n\n## Motivation\n\n[ota-meshi/eslint-plugin-lodash-template](https://github.com/ota-meshi/eslint-plugin-lodash-template) focus on linting by ESLint, so It includes many features.\n\nI want to get simple parser/splitter for lodash template.\n`lodash-template-js-parser` just includes a parser for lodash template, So `lodash-template-js-parser` does not includes JavaScript Parser like espree, babel/parser.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n    npm install lodash-template-js-parser\n\n## Usage\n\n```ts\nexport interface parseTemplateOptions {\n    templateSettings?: {\n        escape?: [string, string];\n        evaluate?: [string, string];\n        interpolate?: [string, string];\n    };\n}\n/**\n * Parse the template and return { script, template } object.\n * @param code The template to parse.\n * @param parserOptions The parser options.\n * @returns The parsing result object.\n */\nexport declare function parseTemplate(template: string, parserOptions: parseTemplateOptions): {\n    script: string;\n    template: string;\n};\n```\n\nExample:\n\n```js\nimport { parseTemplate } from \"lodash-template-js-parser\";\nconst content = `\nconst age = 18;\n\u003c% if (age \u003c 18) { %\u003e\n    \u003cli\u003e\u003c%= name %\u003e (age: \u003c%= age %\u003e)\u003c/li\u003e\n\u003c% } else { %\u003e\n    \u003cli\u003eover the age limit!\u003c/li\u003e\n\u003c% }%\u003e\n`;\nconst { script, template } = parseTemplate(content, {\n    templateSettings: {\n        interpolate: [\"#{\", \"}\"]\n    }\n});\nassert.strictEqual(script, `\n               \n   if (age \u003c 18) {   \n            name ;            age ;   \n   } else {   \n                                \n   }  \n`);\nassert.strictEqual(template, `\nconst age = 18;\n                     \n    \u003cli\u003e            (age:           )\u003c/li\u003e\n              \n    \u003cli\u003eover the age limit!\u003c/li\u003e\n      \n`);\n```\n\n\n## Changelog\n\nSee [Releases page](https://github.com/azu/lodash-template-js-parser/releases).\n\n## Running tests\n\nInstall devDependencies and Run `npm test`:\n\n    npm test\n\n## Contributing\n\nPull requests and stars are always welcome.\n\nFor bugs and feature requests, [please create an issue](https://github.com/azu/lodash-template-js-parser/issues).\n\n1. Fork it!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Commit your changes: `git commit -am 'Add some feature'`\n4. Push to the branch: `git push origin my-new-feature`\n5. Submit a pull request :D\n\n## Author\n\n- [github/azu](https://github.com/azu)\n- [twitter/azu_re](https://twitter.com/azu_re)\n\n## License\n\nMIT © azu\n\nThis project is based on [eslint-plugin-lodash-template](https://github.com/ota-meshi/eslint-plugin-lodash-template).\n\n```\nMIT License\nCopyright (c) 2018 Yosuke Ota\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazu%2Flodash-template-js-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazu%2Flodash-template-js-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazu%2Flodash-template-js-parser/lists"}