xen-orchestra/@xen-orchestra/template/.USAGE.md
Julien Fontanet 471fbef6ef chore: hide USAGE.md
This highlight the fact that it's not designed for direct consumption and it no longer needs a special handling in `npmignore`.
2022-02-18 17:11:52 +01:00

352 B

Create a string replacer based on a pattern and a list of rules.

const myReplacer = compileTemplate('{name}_COPY_{name}_{id}_%%', {
  '{name}': vm => vm.name_label,
  '{id}': vm => vm.id,
  '%': (_, i) => i,
})

const newString = myReplacer(
  {
    name_label: 'foo',
    id: 42,
  },
  32
)

newString === 'foo_COPY_{name}_42_32%' // true