Skip to content
Lightweight templating in 150 bytes
Branch: master
Clone or download
Latest commit eb7957f Aug 14, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
src fix: allow whitespace Aug 12, 2018
test test: show currying; Aug 14, 2018
.gitignore add description & readme Aug 12, 2018
.travis.yml add root files Aug 12, 2018
builder.js add `builder` script Aug 12, 2018
license add root files Aug 12, 2018
package.json 1.1.0 Aug 14, 2018 readme: show whitespace format Aug 12, 2018

templite Build Status

Lightweight templating in 154 bytes

Allows you to denote dynamic portions of a string using double curly brackets ({{ example }}) & then replace them with matching values from your data source.

You may attach an Object or an Array as your data source, which means you may use the object's keys or the array's indices to assign values.

Lastly, you may use dot-notated paths to access (deeply) nested values; eg:, 0.0.0, or


$ npm install --save templite


const templite = require('templite');

templite('Hello, {{name}}!', { name: 'world' });
//=> Hello, world!

templite('Howdy, {{0}}! {{1}}', ['partner', '🤠']);
//=> Howdy, partner! 🤠

templite('foo: "{{foo}}"; bar: "{{bar}}";', { foo: 123 });
//=> foo: "123"; bar: "";

  Name: {{name.last}}, {{name.first}}
  Location: {{}} ({{}})
  Hobbies: {{hobbies.0}}, {{hobbies.1}}, {{hobbies.2}}
`, {
  name: {
    first: 'Luke',
    last: 'Edwards'
  address: {
    city: 'Los Angeles',
    country: 'USA'
  hobbies: ['eat', 'sleep', 'repeat']
//=> Name: Edwards, Luke
//=> Location: Los Angeles (USA)
//=> Hobbies: eat, sleep, repeat


templite(input, values)


Type: String

The string template to operate upon.

Its dynamic placeholders are signified with double curly brackets ({{foo}} or {{ foo }}) and may map to key names or indices. They may also reference deeply nested values via dot-notation (

Unknown keys/indices and null or undefined values are replaced with an empty string ('').


Type: Array or Object

The data source for your template injections.


MIT © Luke Edwards

You can’t perform that action at this time.