1.3.1 • Published 9 years ago

velocity.java v1.3.1

Weekly downloads
57
License
ISC
Repository
github
Last release
9 years ago

velocity.java

NPM

Apache Velocity is a general purpose template engine.
This is a nodejs wrap for Apache Velocity.

Requirements

  • JRE 1.6 or higher

API

velocity.renderOnce(filename, data, callback)

  • filename String
  • data Object
  • root String | Array
  • callback Function

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:

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), where data is the buffer of the rendered template.

velocity.startServer(port)

  • port Number default = 12306
  • callback Function

callback, test whether the JRE exists. Then call the callback argument with either true or false.

velocity.stopServer()

velocity.render(filename, data, callback)

  • filename String
  • data Object
  • root String | Array
  • callback Function

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:

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();
});
1.3.1

9 years ago

1.3.0

9 years ago

1.2.0

9 years ago

1.1.3

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago