gulp-template-ts

4.0.8 • Public • Published

gulp-template-ts

Render/precompile Lo-Dash/Underscore templates

Issues with the output should be reported on the Lo-Dash issue tracker.

Install

$ npm install --save-dev gulp-template-ts

Usage

src/greeting.html

<h1>Hello <%= name %></h1>

gulpfile.ts

import * as gulp from 'gulp';
import * as template from 'gulp-template-ts';
 
gulp.task('default', () =>
    gulp.src('src/greeting.html')
        .pipe(template({name: 'Mathias'}))
        .pipe(gulp.dest('dist'))
);

You can alternatively use gulp-data to inject the data:

import * as gulp from 'gulp';
import * as template from 'gulp-template-ts';
import * as data from 'gulp-data';
 
gulp.task('default', () =>
    gulp.src('src/greeting.html')
        .pipe(data(() => ({name: 'Mathias'})))
        .pipe(template())
        .pipe(gulp.dest('dist'))
);

dist/greeting.html

<h1>Hello Mathias</h1>

API

template(data, [options])

Render a template using the provided data.

template.precompile([options])

Precompile a template for rendering dynamically at a later time.

data

Type: object

Data object used to populate the text.

options

Type: object

Lo-Dash _.template options.

Related

License

MIT © Mathias Døhl

Package Sidebar

Install

npm i gulp-template-ts

Weekly Downloads

10

Version

4.0.8

License

MIT

Last publish

Collaborators

  • doehl