gulp-jsmart

0.1.5 • Public • Published

gulp-jsmart

NPM version Build Status Coverage Status Dependency Status

jSmart plugin for gulp, based on gulp-template and grunt-jsmart

Install

npm install --save-dev gulp-jsmart

Usage

gulpfile.js

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'));
});

API

jsmart(data, options)

data

Type: String|Object Default value: undefined

A value where you can pass your data as

  1. Object
  2. File
  3. 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>

options

Type: Object

options.templatePath

Type: String Default value: undefined

A string value where you can define a Path in your Project where jSmart should load Templates for Inheritance.

License

MIT License

Readme

Keywords

Package Sidebar

Install

npm i gulp-jsmart

Weekly Downloads

1

Version

0.1.5

License

MIT

Last publish

Collaborators