Quick Start

This is the documentation for 1.5.0 version, which is not the latest version. Consider upgrading to 3.4.0.

Using node.js

In some 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}

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 registry.gitlab.com/rosaenlg-projects/docker-rosaenlg -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

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.