gulp-smarty
The gulp plugin to render smarty template from remote api and local data
Install
$ npm install --save-dev gulp-smarty
Usage
"use strict"const gulp = ;const smarty = ;const opt = {}; gulp
You can also refer to gulp.js
in the repository for more usage details.
API
smarty([options])
options
[object][must]
@parms The settings of gulp-smarty, which can be configured in the following two ways
// options type ONE "data":{} "smarty_opt":{}// options type TWO "path":"" "smarty_opt":{}
data
[object]
@key The detail information, especially corresponing data to render the template.
"THE_NAME_OF_THE_HTML_TEMPLATE": // be same with the template name from gulp.src(); // [object] the json data to render the template "src_data":{} "THE_NAME_OF_THE_HTML_TEMPLATE": // another template name from gulp.src(); // [string] the path to json data, which contains the data to render the template "src_data":"THE_FILE_PATH_TO_JSON_DATA.json" "THE_NAME_OF_THE_HTML_TEMPLATE": // another template name from gulp.src(); // [string] remote API, from which you can get data to render the template "src_data":"REMOTE_API" // if the src_data is remote api, the following two optional keys are supported; // [object] the object that wraps data from api, which will replace "{{RES}}" "res_wrapper": "data": "data":"{{RES}}" // [object] the object that is the options of remote API request; // you can set request headers, body, method, etc. here // for more info: https://nodejs.org/api/http.html#http_http_request_options_callback "req_opt": "headers": "Cookie" : "SESSID=abcdefghijklmng" "method": "POST" // [string] body only for POST. // If type of the body is an object, you should parse with querystring.stringify() or JSON.stringify() according to your content-type // for more info: http://stackoverflow.com/questions/9768192/sending-data-through-post-request-from-a-node-js-server-to-a-node-js-server "body": ""
path
[string]
@key The file path to the detail information above, in case the information is too long in gulpfile.js.
One key between data
and path
must be set in options.
smarty_opt
[object]
@key the options supported by the renderer pacakge smarty4js , such as :
"}
The key smarty_opt
is optional in options.
License
MIT ©