1.0.4 • Published 6 years ago

@veams/plugin-templater v1.0.4

Weekly downloads
129
License
MIT
Repository
github
Last release
6 years ago

Veams Templater Plugin (@veams/plugin-templater)

This plugin adds the possibility to render your handlebars templates in an easy way. You can register the engine, templates, partials and helpers and use them directly in other classes.

TypeScript is supported.


Installation

NPM

npm install @veams/plugin-templater --save

Yarn

yarn add @veams/plugin-templater

Usage

import Veams from '@veams/core';
import TemplaterPlugin from '@veams/plugin-templater';
import handlebars from 'handlebars/runtime';
import { templates } from './templates';
import { customHelper } from './helpers';

// Intialize core of Veams
Veams.onInitialize(() => {
   	// Add plugins to the Veams system
	
    // Add plugins to the Veams system
    Veams.use(TemplaterPlugin, {
        engine: handlebars,
        templates: templates,
        helpers: [
            customHelper
        ]
    });
});

Options

OptionTypeDefaultDescription
engine{Function}nullProvide the handlebars engine instance.
templates{Function}nullProvide your precompiled handlebars templates.
partials{Function}nullYou can provide additional partials.
helpers{Array}[[]]Add custom handlebars helpers.

API

When enabled you can render your template by simple executing the Veams.templater.render():

// Render the template
$(body).append(
    Veams.templater.render('test-template', {data: 'custom data passed to partial'})
);
1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago