gulp-template-ts
v4.0.8
Published
Render/precompile Lo-Dash/Underscore templates including ts version. Based on the gulp-template by Sindre Sorhus
Downloads
8
Maintainers
Readme
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
Related
- grunt-template - Grunt version
License
MIT © Mathias Døhl