gulp-underscore-jst-concat

0.0.4 • Public • Published

gulp-underscore-jst-concat

A gulp plugin to compile underscore views to a single JST file.

Install

Install using npm.

$ npm install gulp-underscore-jst-concat --save-dev

Usage

var jade = require('gulp-jade')
var jstConcat = require('gulp-underscore-jst-concat')
 
gulp.task('JST', function () {
  gulp.src('client/app/views/**/*jade')
    .pipe(jade())
    .pipe(jstConcat('jst.js', {
      renameKeys: ['^.*views/(.*).html$', '$1']
    }))
    .pipe(gulp.dest('public/assets'))
})

This compiles all of your client-side views into a single file jst.js, defining this.JST = { /* template fns */ }.

Let's say we have views located at

  • client/app/views/foo.jade and
  • client/app/views/bar/baz.jade.

Given the example's option renameKeys: ['^.*views/(.*).html$', '$1'] those views will now be accessible as compiled lodash template functions via

  • JST['foo'] and
  • JST['bar/baz'].

(Please note that gulp-underscore-jst-concat doesn't have to be used in conjunction with gulp-jade. Any input-stream emitting html-ish file contents will do.)

Options

renameKeys

Type [String, String]

Control your JST keys by RegExp-replacing the input file's path property.

This will default to ['.*', '$&'] (i.e. a template's key will just be it's input file's path).

License

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.4
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.4
    0
  • 0.0.3
    2
  • 0.0.2
    2

Package Sidebar

Install

npm i gulp-underscore-jst-concat

Weekly Downloads

4

Version

0.0.4

License

MIT

Last publish

Collaborators

  • alextaujenis