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 Settings → Document templates.
Comments and tags
There are two ways to add comments to templates:
- Use "/* <Comment text> */". Characters /* define the beginning of the comment, characters */ define its end. A single construction can contain multiple text strings.
- Use "// <Comment text>". A comment is a text after //, the comment ends with a line break.
|<%= (...) %>||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. :
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):
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.
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.