Apache Velocity is a general purpose template engine. This is a nodejs wrap for Apache Velocity.
npm install velocity.java
Apache Velocity is a general purpose template engine.
This is a nodejs wrap for Apache Velocity.
* JRE 1.6 or higher
Render the template specified by filename with data.
root accepts multi-value.
Root(s) from which the loader loads templates.
Templates may live in subdirectories of this root.filename is the relative path to root.
Example:
``javascript`
var velocity = require("velocity.java");
velocity.renderOnce("example.vm", {}, "example/", function(err, data) {
if (err) {
console.error(err);
return;
}
console.log(data.toString());
});
The callback is passed two arguments (err, data),data
where is the buffer of the rendered template.
callback, test whether the JRE exists. Then call the callback argument with either true or false.
Java startup time is often much slower,
because a lot of classes must be loaded before being used.
So, velocity.java provides one simple server to speed up rendering.render usually used after startServer. Example:
`javascript``
var velocity = require("velocity.java");
velocity.startServer(8000);
velocity.render("example.vm", {}, "example/", function(err, data) {
if (err) {
console.error(err);
return;
}
console.log(data.toString());
velocity.stopServer();
});