Quick Start

This is the documentation for 3.2.2 version, which is not the latest version. Consider upgrading to 4.3.0.

Using node.js

Create a folder and go in that folder.

Run npm i rosaenlg to install rosaenlg locally.

In a test.js file:

const rosaenlgPug = require('rosaenlg');

console.log( rosaenlgPug.renderFile('testNLG.pug', {
    language: 'en_US',
    data: ['apples', 'bananas', 'apricots']
}) );

In a testNLG.pug file:

p
  eachz fruit in data with { separator: ',', last_separator: 'and' }
    | #{fruit}

Run node test.js. This will output <p>Apples, bananas and apricots</p>.

In the browser

You can give it a try right now:

and read the browser compilation and rendering documentation.

Using Docker

With fruits.pug on your local filesystem:

- var data = ['apples', 'bananas', 'apricots', 'pears'];
p
  eachz fruit in data with { separator: ',', last_separator: 'and', begin_with_general: 'I love', end:'!' }
    | #{fruit}

On your local command line:

cat fruits.pug | docker run -i rosaenlg/cli:latest -l en_US

You should obtain <p>I love apples, bananas, apricots and pears!</p>.

For more advanced usages, read Docker image for CLI:

  • render files that contain include (which is very common)

  • watch for templates files changes and render them continuously

Once the templates are developed, you can use Docker RosaeNLG server to render them through an API.

Other integrations: Java, API, etc.

If you want to use RosaeNLG in a Java application, or call RosaeNLG through an API, or just use Docker, see the complete integration guide.