1.2.0 • Published 7 years ago

effable v1.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

#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.

ParameterDescriptionTypeDefaultOptional
partialsPathPath to partials.string, booleanfalsetrue
devDisable caching of partials & layouts.booleanfalsetrue
fileExtensionExtension 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.

ParameterDescriptionTypeOptional
nameUsed as a key to get the layout when renderingstringfalse
layoutPathPath to layoutfile.stringfalse
effable.addLayout('main', path.join(__dirname, '/layout/main.html'));

effable.render(templatePath, view, layoutName)

Renders template at specified path.

ParameterDescriptionTypeOptional
templatePathPath to the template you wish to render.stringfalse
viewObject containing data and code for renderer.objectfalse
layoutNameName of layout.stringtrue
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);
});
1.2.0

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago