npm

Need private packages and team management tools?Check out npm Orgs. »

templator

1.1.0 • Public • Published

templator

Lightweight template engine.

js-semistandard-style

templator is a lightweight template engine featuring the following functionality:

  • Replaces {{property_name_1.property_name_2.etc}} with the value of the corresponding property data.property_name_1.property_name_2.etc of a data object passed as a parameter to the module's imported function.

  • Replaces {{> ./relative_path/file_name.ext}} with recursively rendered content of the target file.

  • Recursively renders all files in the srcFolder, except files with names starting with the _ symbol, and places the rendered files in the destFolder.

Installation

$ npm install templator --save-dev

Usage example

const templator = require('templator');
const data = getDataObjectSomehow();
 
templator(srcFolder, destFolder, data)
.then(() => {
  console.log('Success!');
})
.catch(err => {
  console.error(err);
});

API

templator(srcFolder, destFolder, data)

srcFolder {String} - Absolute or relative (to process.cwd()) path to the folder containing the templates.

destFolder {String} - Absolute or relative (to process.cwd()) path to the folder the rendered files to be saved in.

data {Object} - A data object to be used to replace {{property1.property2}} placeholders.

Returns {Promise<Void>}.

install

npm i templator

Downloadsweekly downloads

2

version

1.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability