index.d.ts 746 B

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. Simple micro templating.
  3. @param template - Text with placeholders for `data` properties.
  4. @param data - Data to interpolate into `template`.
  5. @example
  6. ```
  7. import pupa = require('pupa');
  8. pupa('The mobile number of {name} is {phone.mobile}', {
  9. name: 'Sindre',
  10. phone: {
  11. mobile: '609 24 363'
  12. }
  13. });
  14. //=> 'The mobile number of Sindre is 609 24 363'
  15. pupa('I like {0} and {1}', ['🦄', '🐮']);
  16. //=> 'I like 🦄 and 🐮'
  17. // Double braces encodes the HTML entities to avoid code injection
  18. pupa('I like {{0}} and {{1}}', ['<br>🦄</br>', '<i>🐮</i>']);
  19. //=> 'I like &lt;br&gt;🦄&lt;/br&gt; and &lt;i&gt;🐮&lt;/i&gt;'
  20. ```
  21. */
  22. declare function pupa(
  23. template: string,
  24. data: unknown[] | {[key: string]: any}
  25. ): string;
  26. export = pupa;