Skip to content

tomsouthall-zz/gulp-template-compile

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gulp-template-compile

Compile Lo-Dash templates (should work with Underscore templates too).

Synopsis

This is a fork of [https://github.com/ingro/gulp-template-compile].

The major difference is the removal of the namespace functionality for replacement with a simple object assignment. This allows the output code to be wrapped in a closure where no namespacing is required.

Example

gulpfile.js

var gulp = require('gulp');
var template = require('gulp-template-compile');
var concat = require('gulp-concat');

gulp.task('default', function () {
    gulp.src('src/*.html')
        .pipe(template())
        .pipe(concat('templates.js'))
        .pipe(gulp.dest('dist'));
});

API

See the Lo-Dash _.template docs.

template(options)

options

Type: Object

options.name

Type: Function Default: Relative template path. Example: templates/list.html

You can override the default behavior by supplying a function which gets the current File object and is expected to return the name.

Example:

{
    name: function (file) {
        return 'tpl-' + file.relative;
    }
}

options.objectName

Type: String Default: 'templates'

The object to which the precompiled templates will be assigned.

options.templateSettings

Type: Object Default: null

Lo-Dash _.template options.

options.IIFE

Type: 'Boolean' Default: null

Wrap each precompiled template with an IIFE. If you don't need it simply set this option to false.

License

MIT

About

Precompile Lodash templates with Gulp

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%