gulp-jst2
Compile lodash templates to a JST file using gulp; allow customisation of the prepended text while optionally using a RegEx of the file.path (full path, name and extension).
Based on gulp-jst.
Install
Install using npm.
npm install gulp-jst2 --save-dev
Options
jst(options)
prepend
string to prepend before the function returned. Will be used in printf
so can include %s
to insert the string returned from the useFilePath
option. Default: false
.
useFilePath
array containing [RegEx
, string
] to return all or part of the current file's path. Default returns filename without extension. Default: ['^.*/(.+?)(\.[^.]*$|$)', '$1']
gulp-jst2
also accepts the same _.template options and passes them on to the lodash library.
Usage
Defaults will simply return the lodash function:
var gulp = jst = ; gulp; gulp;
You can prepend
a simple string before the function to produce a variable assignment like so:
var gulp = jst = ; gulp; gulp;
You can prepend
with the %s
option to include the default filename of the current file within your string before the function to produce a variable assignment like so:
var gulp = jst = ; gulp; gulp;
You can prepend
with the %s
option to include the RegEx
of the file.path
of the current file within your string before the function to produce a variable assignment like so:
var gulp = jst = ; gulp; gulp;
Really Useful Usage
Create a single javaScript file containing a custom global object
with a key templates
whose subkeys are the filename
of templates from a single directory and their values are the templates. Also minify the HTML and uglify the javaScript, like so:
var gulp = htmlmin = jst = concat = insert = uglify = ; gulp; gulp;