BILLmanager Documentation

EJS-code syntax


EJS (Express.js) is a web application framework for Node.js. In BILLmanager EJS is implemented with the /usr/local/mgr5/etc/scripts/template_ejs.js script. For correct operation, the incoming XML-file is converted to a JSON file. 

The EJS language describes document and message templates in BILLmanager. To add or edit templates, navigate to  SettingsDocument templates.

EJS-code syntax 

Comments and tags

There are two ways to add comments to templates: 

  1. Use  "/* <Comment text> */". Characters /* define the beginning of the comment,  characters */ define its end. A single construction can contain multiple text strings. 
  2. Use   "// <Comment text>". A comment is a text after //, the comment ends with a line break. 

In the template code, JavaScript expressions, HTML, and comments are put into special tags.

JavaScript expressions <% (...) %>The tags define JavaScript operations


<%= (...) %>The tags escape  HTML-constructions
<%- (...) %>The tags output information with unescaped buffering
Comments<%# (...) %>The tags highlight the comments


A variable declaration starts with the keyword var followed by the variable name, e.g. :

var myVariable;

The variable declaration ends with a semi-colon. The names of the variables in EJS-templates are case-sensitive: myVariable and myvariable are different variables. 

Variable data type is defined bases on the value (optional): 

var myText = 'Text variable'; //A string is put into single quotes. 
var myNumber = 10; // Numeric data type. The value is specified without quotes. 
var myBoolean = true; // Booling data type. true and false are key words, they are not put into quotes. 
var myObject = document.querySelector('h1'); // This variable is used for saving the objects. It can keep any object of the billing system. 
var myArray = [1, 'Payer', 2, 'Provider']; //Data array. It allows to keep many elements. 


In  EJS-template the information can be represented with the help of several elements: 

  • formatting blocks. The are specified with the tags  <div> (...) </div>;
  • tables. The are specified with the tags <table> (...) </table>;
  • lists. The are specified with the tags <ul> (...) </ul>;
  • links to images. The are specified with the tag <img src=(...)/>.  

Document print layout is based on the elements and their formatting parameters described in the code. 

For more information, please refer to the article Contents

Logical operators

Conditions in an EJS-template enable to check if a statement is true and execute a code fragment depending on its result. 

For example, if the payer type is "Company", the system must show a  VAT number in the printing document. 

For more information about how to use logical operators in EJS-templates, please refer to the article Logical operators


Functions allow using a  certain piece of code multiple times without the need to write it again. You need to add a function only once and call the function in the code by its name. 

For example, in the "date' function a developer described a piece of code to change the numerical value of a month into the letter symbols. This function can be used in the invoice name and payment purpose. You will only need to specify a function name. 

For more information, please refer to the article Functions.

Thank you for your feedback!
Was the article useful?
Tell us why not:

it does not match the title

it was hard to understand

I didn't find the answer

recommendations from the article did not help


Tell us what you didn't like in the article: