1.0.4 • Published 6 years ago

ejs-json v1.0.4

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

ejs-json

ejs、data plugin for gulp

Usage

First, install ejs-json as a development dependency:

npm install --save-dev ejs-json

second,ready your html and data file like this:

-src
---index.html
---index.json
---header.ejs

index.html include header.ejs,using index.json.

Then, add it to your gulpfile.js:

var ejs = require("ejs-json")

//compile ejs
gulp.task('compile-ejs', function () {
    return gulp.src('./src/*.html')
        .pipe(ejs({"data":"./src/data"}))
        .pipe(gulp.dest("./dist"))
});

This plugin will auto loading the json in your data url,like "./src/data".

if you has more files and datas , they will auto compiles , too.

API

ejs(data, options, settings)

data

Type: url Default: {"data":url}

//use like
ejs({"data":"./src/data"})

options

Type: hash Default: {}

A hash object for ejs options.

For more info on ejs options, check the project's documentation.

settings

Type: hash Default: {}

A hash object to configure the plugin.

settings.ext

Type: String Default: undefined

Defines the file extension that will be appended to the filename. If no extension is provided, the same extension of the input file will be used.

Note: As of v2.0.0 the output file extension is no longer .html by default, you need to specify it, otherwise it will have the same extension of the input file.