{"id":16012457,"url":"https://github.com/ezhlobo/pug-uses-variables","last_synced_at":"2025-06-18T00:34:36.313Z","repository":{"id":25365993,"uuid":"103821536","full_name":"ezhlobo/pug-uses-variables","owner":"ezhlobo","description":"Find all JavaScript variables used in pug template","archived":false,"fork":false,"pushed_at":"2023-01-04T00:46:04.000Z","size":1270,"stargazers_count":2,"open_issues_count":14,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-20T01:19:43.811Z","etag":null,"topics":["ast","babel","library","pug","pug-templates","react"],"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/ezhlobo.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":"2017-09-17T10:45:30.000Z","updated_at":"2023-01-31T16:52:51.000Z","dependencies_parsed_at":"2023-01-14T03:45:13.803Z","dependency_job_id":null,"html_url":"https://github.com/ezhlobo/pug-uses-variables","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/ezhlobo/pug-uses-variables","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezhlobo%2Fpug-uses-variables","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezhlobo%2Fpug-uses-variables/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezhlobo%2Fpug-uses-variables/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezhlobo%2Fpug-uses-variables/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ezhlobo","download_url":"https://codeload.github.com/ezhlobo/pug-uses-variables/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezhlobo%2Fpug-uses-variables/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260462523,"owners_count":23013126,"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":["ast","babel","library","pug","pug-templates","react"],"created_at":"2024-10-08T14:03:31.815Z","updated_at":"2025-06-18T00:34:31.301Z","avatar_url":"https://github.com/ezhlobo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pug-uses-variables [![circleci](https://circleci.com/gh/ezhlobo/pug-uses-variables/tree/master.svg)](https://circleci.com/gh/ezhlobo/pug-uses-variables/tree/master)\n\nFind all JavaScript variables used in pug template.\n\n## Usage\n\n```\n$ npm install --save pug-uses-variables\n```\n\n```js\nconst { findVariablesInTemplate } = require('pug-uses-variables')\n\nconst pugTemplate = `\n\n  ReactComponent(property=object[item])\n    = content\n\n    if condition === matcher\n      p Truthy\n\n`.trimRight()\n\nconst variables = findVariablesInTemplate(pugTemplate)\n```\n```js\n// `variables` is equal:\n[{\n  value: 'ReactComponent',\n  loc: {\n    start: { line: 3,  column: 2 },\n    end:   { line: 3,  column: 14 }\n  }\n}, {\n  value: 'object',\n  loc: {\n    start: { line: 3,  column: 24 },\n    end:   { line: 3,  column: 30 }\n  }\n}, {\n  value: 'item',\n  loc: {\n    start: { line: 3,  column: 31 },\n    end:   { line: 3,  column: 35 }\n  }\n}, {\n  value: 'content',\n  loc: {\n    start: { line: 4,  column: 4 },\n    end:   { line: 4,  column: 11 }\n  }\n}, {\n  value: 'condition',\n  loc: {\n    start: { line: 6,  column: 5 },\n    end:   { line: 6,  column: 14 }\n  }\n}, {\n  value: 'condition',\n  loc: {\n    start: { line: 6,  column: 19 },\n    end:   { line: 6,  column: 26 }\n  }\n}]\n```\n\n**Important**: templates should be right-trimmed. Usually it means that you have to execute `.trimRight` on your template-string as in the example above.\n\n### Get variable names only\n\n```js\nconst variableNames = variables.map(variable =\u003e variable.value)\n// \u003e ['ReactComponent', 'object', 'item', 'content', 'condition', 'matcher']\n```\n\n## Value\n\nThis plugin helps us to integrate [babel-plugin-transform-react-pug](https://github.com/pugjs/babel-plugin-transform-react-pug) and [eslint](http://eslint.org).\n\n## Development\n\n* `yarn test`\n* `yarn lint`\n\n## License\n\n[MIT](https://tldrlegal.com/license/mit-license)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fezhlobo%2Fpug-uses-variables","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fezhlobo%2Fpug-uses-variables","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fezhlobo%2Fpug-uses-variables/lists"}