{"name":"pupa","version":"3.2.0","keywords":["string","formatting","template","object","format","interpolate","interpolation","templating","expand","simple","replace","placeholders","values","transform","micro"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"pupa@3.2.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/pupa#readme","bugs":{"url":"https://github.com/sindresorhus/pupa/issues"},"dist":{"shasum":"5974e89aa0c0c732a8b96211bcfd0ebd086a778d","tarball":"http://registry-npm.ywwl.com/pupa/download/pupa-3.2.0.tgz","fileCount":5,"integrity":"sha512-sG2emmGYr2k03h3YOy8PfIYSrv6WYPciaURligFB7+G8adrS0Yx9+8ctHAbz+QAwZqUuk+rdHV1aXP5krS6fpg==","signatures":[{"sig":"MEYCIQC9NFjbEHrsoDAIyNwc6/dIToTfvRmNicwzRNXEp+K6xgIhAPEySJXm0ybKOue9lW7g/iIX0q3gw8yYfKULPaX/ktuc","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10298,"size":3987,"noattachment":false,"key":"/pupa/-/pupa-3.2.0.tgz"},"type":"module","types":"./index.d.ts","engines":{"node":">=12.20"},"exports":"./index.js","funding":"https://github.com/sponsors/sindresorhus","gitHead":"ed6d99a6b5b96867f7742109e291905bb7280de5","scripts":{"test":"xo && ava && tsd"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/pupa.git","type":"git"},"_npmVersion":"10.9.2","description":"Simple micro templating","directories":{},"sideEffects":false,"_nodeVersion":"20.19.1","dependencies":{"escape-goat":"^4.0.0"},"_hasShrinkwrap":false,"devDependencies":{"xo":"^0.41.0","ava":"^3.15.0","tsd":"^0.17.0"},"_npmOperationalInternal":{"tmp":"tmp/pupa_3.2.0_1757962415775_0.9111640685599662","host":"s3://npm-registry-packages-npm-production"},"readme":"# pupa\n\n> 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//=> 'The mobile number of Sindre is 609 24 363'\n\npupa('I like {0} and {1}', ['🦄', '🐮']);\n//=> 'I like 🦄 and 🐮'\n\n// Double braces encodes the HTML entities to avoid code injection.\npupa('I like {{0}} and {{1}}', ['<br>🦄</br>', '<i>🐮</i>']);\n//=> 'I like &lt;br&gt;🦄&lt;/br&gt; and &lt;i&gt;🐮&lt;/i&gt;'\n\n// Escaped dots in property names\npupa('The version is {package\\\\.version}', {\n\t'package.version': '1.0.0'\n});\n//=> 'The version is 1.0.0'\n\n// Escape literal braces\npupa('Use \\\\{key\\\\} syntax for placeholders', {});\n//=> 'Use {key} syntax for placeholders'\n\npupa('Hi {name}! Use \\\\{key\\\\} for placeholders', {name: 'John'});\n//=> 'Hi John! Use {key} for placeholders'\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. Supports filter syntax: `{key | filter1 | filter2}`.\n\nUse `\\{` and `\\}` to include literal braces in the output.\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\nYou can escape dots in placeholder keys with backslashes (e.g., `{foo\\\\.bar}` accesses the property `'foo.bar'` instead of `foo.bar`).\n\n#### options\n\nType: `object`\n\n##### ignoreMissing\n\nType: `boolean`\\\nDefault: `false`\n\nBy default, throws a `MissingValueError` when a placeholder resolves to `undefined`. When `true`, ignores missing values and leaves the placeholder as-is.\n\n##### transform\n\nType: `function` (default: `({value}) => value`)\n\nTransform function called for each interpolation. If it returns `undefined`, behavior depends on the `ignoreMissing` option. Otherwise, the returned value is converted to a string (and HTML-escaped when using double braces).\n\n##### filters\n\nType: `object`\\\nDefault: `{}`\n\nFilters to apply to values.\n\nFilters can be chained using the pipe syntax: `{name | uppercase | reverse}`.\n\n```js\nimport pupa from 'pupa';\n\nconst filters = {\n\ttrim: value => value.trim(),\n\tuppercase: value => value.toUpperCase()\n};\n\npupa('{name | trim | uppercase}', {name: 'john '}, {filters});\n//=> 'JOHN'\n```\n\n### MissingValueError\n\nExposed for instance checking.\n\n### MissingFilterError\n\nExposed for instance checking.\n\nThrown when a filter is used that doesn't exist in the `filters` option.\n\n## FAQ\n\n### What about template literals?\n\nTemplate literals are evaluated when the code runs. This module evaluates templates when you call it, which is useful when templates or data are created dynamically or come from user input.\n\n### Will filters support parameters?\n\nNo. Filters are simple functions that take a single value and return a transformed value. For complex transformations requiring parameters, use the `transform` option instead.\n\n### Are there built-in filters?\n\nNo. This keeps the package minimal and focused. You can easily define your own filters.\n\n## Related\n\n- [pupa-cli](https://github.com/sindresorhus/pupa-cli) - CLI for this module\n","publish_time":1757962415959,"_cnpm_publish_time":1757962415959,"dist-tags":{"latest":"3.3.0"}}