• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ingro/gulp-template-compile: Precompile Lodash templates with Gulp

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

ingro/gulp-template-compile

开源软件地址(OpenSource Url):

https://github.com/ingro/gulp-template-compile

开源编程语言(OpenSource Language):

JavaScript 100.0%

开源软件介绍(OpenSource Introduction):

gulp-template-compile

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

Synopsis

This plugin is heavily inspired by Sindre Sorhus's gulp-nunjucks plugin, in fact I used it as skeleton for creating this one.

Install

Install with npm

npm install --save-dev gulp-template-compile

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

Type: String Default: 'JST'

The namespace in which the precompiled templates will be assigned. Starting from version 1.0 you could also provide a dotted namespace that will be correctly handled, thanks to fhawkes. For example 'custom.namespace' will result in window['custom']['namespace'].

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.

Changelog

1.3.0:

  • FEATURE: Added options.IIFE #14

1.0.0:

  • BREAKING: Added support for custom dotted namespaces.

Notes

If you use grunt instead of gulp, but want to perform a similar task, use grunt-contrib-jst.

License

MIT © Emanuele Ingrosso




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap