jSmart plugin for gulp, based on gulp-template and grunt-jsmart
npm install --save-dev gulp-jsmart
This example shows how one might convert glob of templates, and rename them with gulp-rename
var gulp = require('gulp');
var jsmart = require('gulp-jsmart');
var rename = require('gulp-rename');
var options = {
templatePath: 'app/templates/',
};
gulp.task('default', function () {
return gulp.src('src/templates/*.tpl')
.pipe(jsmart('src/data/', options))
.pipe(rename({extname: '.html'}))
.pipe(gulp.dest('dist'));
});
Type: String
|Object
Default value: undefined
A value where you can pass your data as
- Object
- File
- Directory
If you pass your data as JSON-File or Directory Containing JSON-Files, the first Level
in Object-Hierarchy is the Name of the JSON-File (Underscores, Hyphens etc. are converted to camelCase!).
E.g. Your Filename is book-store.json
with the content
{
"greeting": "Hi, there are some JScript books you may find interesting:"
}
you must use it in your template like this:
<h1>{$bookStore.greeting}</h1>
Type: Object
Type: String
Default value: undefined
A string value where you can define a Path in your Project where jSmart should load Templates for Inheritance.