freemarker
v2.0.1
Published
Freemarker integration for NodeJS.
Downloads
4,273
Readme
freemarker
Freemarker integration for NodeJS
How to use
JAVA_HOME
should be set properlynpm i freemarker -S
Render string
const Freemarker = require('freemarker');
const freemarker = new Freemarker();
freemarker.render('<h1>${title}</h1>', { title: 'test render' }, (err, result) => {
if (err) {
throw new Error(err);
}
console.log(result);
});
NOTICE: Don't use #include
in string for rendering.
Render file
const Freemarker = require('freemarker');
const freemarker = new Freemarker({ root: __dirname });
freemarker.renderFile(path.join(__dirname, 'index.ftl'), data, (err, result) => {
if (err) {
throw new Error(err);
}
console.log(result);
});
In this example, path.join(__dirname, 'index.ftl')
can be replaced with index
or index.ftl
Test
node v6+
npm test
Known issues
null
is not supported
LICENSE
MIT