Skip to content

m59peacemaker/js-interpol8

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published