@marcopeg/template

1.12.0 • Public • Published

@marcopeg/template

Minimalist variable substitution utility inspired by mustache that implements just few variable substitution features.

  • no loops
  • no conditionals
  • no filters

If you need a full template engine, use mustache :-)

import template from '@marcopeg/template'

const data = {
    name: 'marco',
    surname: 'pegoraro',
    family: {
        father: { name: 'piero' },
        mother: { name: 'teresa' },
        siblings: [
            { name: 'giulia' },
            { name: 'elisa' },
        ]
    }
}

template('name', name)
// -> marco

template('{{ name }} {{ surname }}', data)
// -> marco pegoraro

template('{{ name }} {{ surname }} has {{ family.siblings.$LENGTH }} siblings', data)
// -> marco pegoraro has 2 siblings

Dependents (2)

Package Sidebar

Install

npm i @marcopeg/template

Weekly Downloads

54

Version

1.12.0

License

MIT

Unpacked Size

4.94 kB

Total Files

7

Last publish

Collaborators

  • marcopeg