file-factory
Generate Files From A JSON File And A Basic Template.
Usage
Assume you wanna generate files reference to a specify template:
_layout
%%title %%heading
And you have a JSON file list all of the files information:
meta.json
"index.html": "title": "GULP FILE FACTORY" "description": "index.html did not sepcify `dest` in this file." "keywords": "so it will store in the directory of `www`" "heading": "The Page Index" "foo.html": "title": "FOO" "description": "foo.html sepcify `dest` in this file." "keywords": "so it will store in the directory of `./page/foo`" "heading": "The Page Foo" "dest": "./page/foo" "bar.html": "title": "BAR" "description": "bar.html sepcify `dest` in this file." "keywords": "so it will store in the directory of `../../page/bar`" "heading": "The Page Bar" "dest": "../../page/bar"
Rusult:
www/index.html
GULP FILE FACTORY The Page Index
page/foo/foo.html
FOO The Page Foo
page/bar/bar.html
(this file will be created to the upper directories relative to your current work directory)
BAR The Page Bar
How To Use
First, install file-factory
as a development dependency:
npm install --save-dev file-factory
Use with nodejs
file-factory.js
var fileFactory = ; ;
run:
node file-factory
Running in gulp task
gulpfile.js
var gulp = ;var fileFactory = ; gulp
run:
gulp file-factory
API
fileFactory(options)
options
Type: Object
options.layout
Type: String
The template for all of generated files.
options.meta
Type: String
The data of the specify files.
options.dest
Type: String
Default: www
The directory where the generated files store,
this field will be cover by the field dest
which defined in the file where options.meta specify.
options.identify
Type: String
Default: %%
The prefix of the search string.