[go: up one dir, main page]

interpol8

1.0.2 • Public • Published

interpol8

Basic templating by interpolating values into placeholders.

install

npm install interpol8

example

const interpolate = require('interpol8')
 
interpolate(
  'Hello, {{place}}',
  {place: 'world'}
) // -> 'Hello, world'
 
// nested, arrays, brackets, dots, whatever, it all works as one would expect
interpolate(
  'Hello, {{[0].foo.bar["places"][1]}}',
  [{foo: bar: {{places: ['', 'world']}}}]
) // -> 'Hello, world'
 
// custom delimiters
interpolate(
  'Hello, <% place %>',
  {place: 'world'},
  {left: '<%', right: '%>'}
) // -> 'Hello, world'

API

interpolate(template, data, options)

  • template: string
  • data: object
  • options: object
    • left: string, {{ left delimiter
    • right: string, }} right delimiter

Package Sidebar

Install

npm i interpol8

Weekly Downloads

1

Version

1.0.2

License

CC0-1.0

Last publish

Collaborators

  • m59