Simple micro templating
npm install pupa-cli> Simple micro templating
``sh`
npm install --global pupa-cli
`
$ pupa --help
Usage
$ pupa [options]
Options
--filters, -f
Examples
$ echo 'The mobile number of {name} is {mobile}' | pupa --name=Sindre --mobile='609 24 363'
The mobile number of Sindre is 609 24 363
$ echo 'I like {0} and {1}' | pupa 🦄 🐮
I like 🦄 and 🐮
$ echo 'Hello {{0}}' | pupa 'World'
Hello <b>World</b>
Using custom filters:
$ echo 'Hello {name | uppercase}' | pupa --name=world --filters='{uppercase: v => v.toUpperCase()}'
Hello WORLD
$ echo '{text | trim | reverse}' | pupa --text=' hello ' --filters='{trim: v => v.trim(), reverse: v => [...v].reverse().join("")}'
olleh
`
Filters allow you to transform template values using the pipe syntax: {value | filter}. You can chain multiple filters: {value | filter1 | filter2}.
Define filters using the --filters option with a JavaScript object literal:
`sh`
$ echo '{name | uppercase | reverse}' | pupa --name=hello --filters='{uppercase: v => v.toUpperCase(), reverse: v => [...v].reverse().join("")}'
OLLEH
`js``
{
uppercase: v => v.toUpperCase(),
lowercase: v => v.toLowerCase(),
trim: v => v.trim(),
reverse: v => [...v].reverse().join(''),
length: v => v.length.toString()
}
- pupa - API for this package