xen-orchestra/@xen-orchestra/template
Julien Fontanet 2a70ebf667 docs: uniformize code blocks
- add missing syntaxes
- don't put prompt if no command outputs to ease copy/paste and use `sh` syntax
- always use `$` as prompt and use `console` syntax
2023-02-06 11:25:12 +01:00
..
.npmignore feat: unified .npmignore for all packages 2021-04-07 13:58:14 +02:00
.USAGE.md chore: hide USAGE.md 2022-02-18 17:11:52 +01:00
index.js chore(template): remove build step 2022-06-23 17:24:54 +02:00
index.test.js test(template): from Jest to test (#6499) 2022-11-04 10:53:38 +01:00
package.json test(template): from Jest to test (#6499) 2022-11-04 10:53:38 +01:00
README.md docs: uniformize code blocks 2023-02-06 11:25:12 +01:00

@xen-orchestra/template

Package Version License PackagePhobia Node compatibility

Install

Installation of the npm package:

npm install --save @xen-orchestra/template

Usage

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

Contributions

Contributions are very welcomed, either on the documentation or on the code.

You may:

  • report any issue you've encountered;
  • fork and create a pull request.

License

ISC © Vates SAS