Rendering Templates

Introduction

Provision is made for rendering abstract HTML trees with data. This functionality is implemented using Embedded JavaScript.

Templating Overview

The HTML is rendered if it has valid EJS syntax and also has the right context.

The templating object is exposed on EntityRepo's Infrastructure object and can be accessed using -

this.entityRepo
.infrastructure()
.templating.render(VALID_EJS_HTML_STRING, CONTEXT);

HTML templates can be created using the Dynamo-admin interface Manage Templates process. The reports are saved in a Report schema. An abstraction has been provided to work with Report templates and the Templating render function (The GetHtml library).

Usage of this library is given as -

this.libs.getHtml(REPORT_UID, CONTEXT, DOMAIN_ID, (error, report) => {
...
let renderedTemplate = report.render();
});

or

this.libs.getHtmlTemplates([
[REPORT_UID, CONTEXT], ...
], DOMAIN_ID, (error, reports) => {
...
let renderedTemplate = reports.reduce((aggregate, report) => {
return aggregate + report.render();
}, "");
});