An indexed template processor
  • JavaScript 100%
Find a file
2016-07-06 21:40:49 -04:00
.gitattributes 🎉 Added .gitattributes & .gitignore files 2016-07-06 20:25:49 -04:00
.gitignore 🎉 Added .gitattributes & .gitignore files 2016-07-06 20:25:49 -04:00
index.js Add tests, account for dupe keys. 2016-07-06 20:50:23 -04:00
LICENSE.md Add ISC license 2016-07-06 20:51:24 -04:00
package.json Setting up package 2016-07-06 20:27:10 -04:00
README.md Add documentation. 2016-07-06 21:01:38 -04:00
spec.js Test with tic-tac-toe 2016-07-06 21:40:49 -04:00

Indexed Template

Process indexed template literals.

Example

let template = require('indexed-template');

let text = template`Hello ${0}!`('Sandy');
// Hello Sandy!

let fn = template`${0} knows ${1}, and ${1} knows ${0}.`;

fn('Elizabeth', 'Francis');
fn('Jake', 'Jim');
// Elizabeth knows Francis, and Francis knows Elizabeth.
// Jake knows Jim, and Jim knows Jake.

Installation

$ npm install indexed-template

API

var template = require('indexed-template');

templatetemplate literal(...values))

  • template literal {string.raw} A template literal where each expression evaluates to an integer
  • parameter {...*} value: A value to be placed into the literal string matching the indexed value to the expressions integer.
  • returns string: A string representing the template populated with the values.