This package has been deprecated

Author message:

This project is no longer being maintained.

effable

1.2.0 • Public • Published

#effable

A simple mustache wrapper for nodejs.

effable is written using modern Javascript features (such as Promise & async/await) and requires a nodejs version of 7.7.1 or higher.

npm install effable

Usage

const Effable = require('effable');
const effable = Effable(partials, dev, fileExtension);

Effable(partialsPath, dev, fileExtension)

Create a new effable instance. Factory constructor, ie. dont call with new keyword.

Parameter Description Type Default Optional
partialsPath Path to partials. string, boolean false true
dev Disable caching of partials & layouts. boolean false true
fileExtension Extension to use when loading partials. boolean 'html' true

effable.set(options)

Modify options.

effable.set({ dev: true, fileExtension: "mu" });

effable.addLayout(name, layoutPath)

Adds a layout with the specified name and path.

Parameter Description Type Optional
name Used as a key to get the layout when rendering string false
layoutPath Path to layoutfile. string false
effable.addLayout('main', path.join(__dirname, '/layout/main.html'));

effable.render(templatePath, view, layoutName)

Renders template at specified path.

Parameter Description Type Optional
templatePath Path to the template you wish to render. string false
view Object containing data and code for renderer. object false
layoutName Name of layout. string true
effable.render(path.join(__dirname, '/view/index.html'), { stuff: "Hello World!"  }, 'main').then((output) => {
    console.log(output);
}).catch((err) => {
    console.log(err);
});

// using async/await:
let output = await effable.render(path.join(__dirname, '/view/index.html'), { stuff: "Hello World!"  }, 'main');

Example

const effable = require('effable')("path/to/partials");

effable.addLayout('main', path.join(__dirname, '/layout/main.html'));

effable.render(path.join(__dirname, '/view/index.html'), { stuff: "Hello World!"  }, 'main').then((output) => {
    console.log(output);
}).catch((err) => {
    console.log(err);
});

Readme

Keywords

none

Package Sidebar

Install

npm i effable

Weekly Downloads

1

Version

1.2.0

License

MIT

Last publish

Collaborators

  • oskarbraten