template-conv
TypeScript icon, indicating that this package has built-in type declarations

0.0.0 • Public • Published

template-conv

Convert simple templates.

import convertTemplate from "template-conv";
const result = "hello world!";
const tests = [
  ["hello $0!", "world"],
  ["hello $0$1", ["world", "!"]],
  [
    "$111 $1$11",
    {
      $111: "hello",
      $1: "world",
      $11: "!",
    },
  ],
  [
    (a) => {
      const world = a.$0 === "hello" ? "world" : "";
      return `$0 ${world}!`;
    },
    "hello",
  ],
];
tests.map(([template, args]) => {
  console.assert(convertTemplate(template, args) === result);
});

Package Sidebar

Install

npm i template-conv

Weekly Downloads

2

Version

0.0.0

License

MIT

Unpacked Size

3.06 kB

Total Files

5

Last publish

Collaborators

  • startracex