{"id":13447597,"url":"https://github.com/sindresorhus/pupa","last_synced_at":"2025-05-15T10:02:13.035Z","repository":{"id":44035326,"uuid":"78499392","full_name":"sindresorhus/pupa","owner":"sindresorhus","description":"Simple micro templating","archived":false,"fork":false,"pushed_at":"2022-12-21T21:51:27.000Z","size":21,"stargazers_count":362,"open_issues_count":2,"forks_count":21,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-05-11T18:35:03.563Z","etag":null,"topics":["interpolation","npm-package","placeholder","string","template-","template-engine","template-library","templating"],"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/sindresorhus.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2017-01-10T05:02:16.000Z","updated_at":"2025-04-17T16:24:14.000Z","dependencies_parsed_at":"2022-09-05T18:00:43.190Z","dependency_job_id":null,"html_url":"https://github.com/sindresorhus/pupa","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/sindresorhus%2Fpupa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fpupa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fpupa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fpupa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/pupa/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254319717,"owners_count":22051072,"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":["interpolation","npm-package","placeholder","string","template-","template-engine","template-library","templating"],"created_at":"2024-07-31T05:01:22.026Z","updated_at":"2025-05-15T10:02:12.012Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["JavaScript","others","Framework agnostic packages"],"sub_categories":["General utilities"],"readme":"# pupa\n\n\u003e Simple micro templating\n\nUseful when all you need is to fill in some placeholders.\n\n## Install\n\n```sh\nnpm install pupa\n```\n\n## Usage\n\n```js\nimport pupa from 'pupa';\n\npupa('The mobile number of {name} is {phone.mobile}', {\n\tname: 'Sindre',\n\tphone: {\n\t\tmobile: '609 24 363'\n\t}\n});\n//=\u003e 'The mobile number of Sindre is 609 24 363'\n\npupa('I like {0} and {1}', ['🦄', '🐮']);\n//=\u003e 'I like 🦄 and 🐮'\n\n// Double braces encodes the HTML entities to avoid code injection.\npupa('I like {{0}} and {{1}}', ['\u003cbr\u003e🦄\u003c/br\u003e', '\u003ci\u003e🐮\u003c/i\u003e']);\n//=\u003e 'I like \u0026lt;br\u0026gt;🦄\u0026lt;/br\u0026gt; and \u0026lt;i\u0026gt;🐮\u0026lt;/i\u0026gt;'\n```\n\nNote: It does not support nesting placeholders: `pupa('{phone.{type}}', …)`\n\n## API\n\n### pupa(template, data, options?)\n\n#### template\n\nType: `string`\n\nText with placeholders for `data` properties.\n\n#### data\n\nType: `object | unknown[]`\n\nData to interpolate into `template`.\n\nThe keys should be a valid JS identifier or number (`a-z`, `A-Z`, `0-9`).\n\n#### options\n\nType: `object`\n\n##### ignoreMissing\n\nType: `boolean`\\\nDefault: `false`\n\nBy default, Pupa throws a `MissingValueError` when a placeholder resolves to `undefined`. With this option set to `true`, it simply ignores it and leaves the placeholder as is.\n\n##### transform\n\nType: `((data: {value: unknown; key: string}) =\u003e unknown) | undefined` (default: `({value}) =\u003e value`)\n\nPerforms arbitrary operation for each interpolation. If the returned value was `undefined`, it behaves differently depending on the `ignoreMissing` option. Otherwise, the returned value will be interpolated into a string (and escaped when double-braced) and embedded into the template.\n\n### MissingValueError\n\nExposed for instance checking.\n\n## FAQ\n\n### What about template literals?\n\nTemplate literals expand on creation. This module expands the template on execution, which can be useful if either or both template and data are lazily created or user-supplied.\n\n## Related\n\n- [pupa-cli](https://github.com/sindresorhus/pupa-cli) - CLI for this module\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fpupa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fpupa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fpupa/lists"}