gulp-json-replace
Replace string from a json file.
Usage
Assume you wanna replace the title and the description/keywords of the html file:
index.html, signin/signin.html, signup/signup.html
%%title
And you had the config file that contains all of the pages meta infomation:
config.json
"index.html": "title": "GULP JSON REPLACE" "description": "description for the main page" "keywords": "keywords for the main page" "signin/signin.html": "title": "Sign In" "description": "description for the page sign in" "keywords": "keywords for the page sign in" "signup/signup.html": "title": "Sign Up" "description": "description for the page sign up" "keywords": "keywords for the page sign up"
Rusult:
index.html
GULP JSON REPLACE
signin/signin.html
Sign In
signup/signup.html
Sign Up
First, install gulp-json-replace
as a development dependency:
npm install --save-dev gulp-json-replace
Then, add it to your gulpfile.js
:
var jr = ; gulp
API
replace(options)
options
Type: Object
options.src
Type: String
or Object
Accept the path of json file, or an JavaScript Object Literals.
options.identify
Type: String
Default: %%
The string to identify the search field.
options.mode
Type: String
Default: strict
Specify the match mode, the value would be strict
or loose
, if set to loose
, it will ignore the file extension. For example: "index.html" will match files of "index.hbs", "index.html", "index.xxx"...