ftl2html
ftl2html is a clean, just one dependency Node.js module invoke fmpp convert freemarker and data to html.
You need to Install Java Runtime Environment(JRE) 1.7+ first.
Installation
via npm:
$ npm install ftl2html
example
ftlPath:
/test/_src/normal.ftl
/test/_src/parseObj.ftl
tddPath:
/test/_tdd/normal.tdd
/test/_tdd/parseObj.tdd
targetPath:
/test/_target/
just run:
var f = sourceRoot: "_src" dataRoot: "_tdd" outputRoot: "_target"; f;
it will do find the match one and compile it, then put it into targetPath. if you want extra tdd file(relative to tddPath), you can add it's path(string or Array) when you call render. like :
f;
API
recommand usage:
just setup sourceRoot and dataRoot. it will find the same fileName in these path and covert it, more example in test.
var f = initConfig;
initConfig parameter:
- sourceRoot: freemarker template folder path (require)
- dataRoot: mock data folder path (require)
- outputRoot: save converted html path (require)
- isDebug: set true will print every fmpp command before execute, default is false
- javaPath: use specify java if you need, default is "java"
- jarPath: use specify fmpp.jar if you need, default is jar in module
- async: convert ftl async or not, default is true
- tddFiles: common tdd file for all ftl convert
- logFile: fmpp convert log, default is none
- configFile: any extra fmpp config
f;
- ftlFile: covert ftl file name, relative to sourceRoot
- callback: every ftl coverted will be call
- done: all ftl coverted will be call
render method will extend it's config with initConfig, any common config should be put in initConfig.
compatible usage:
for some old project, won't update.
var ftl2html = ; // compile;
- ftlPath: freemarker template file path
- outputPath: convert to html save path
- ftlFileName: freemarker template file name, relative to ftlPath
- tddFiles: mock data file(reference fmpp manual)
- logFile: fmpp convert log, default is none
extend freemarker syntax
var user = $JSONObject;var fids = $JSONArray;
Syntax
It just like freemarker syntax with a little extend. Here is a simple example:
<i>${test1}</i><i>${test2!"no"}</i><i>${common}</i>
combine data
become
test1nocommon
Node.js Support
4+
Manual
License
MIT