Template Tags

The code generator processes the following template tags inside the templates to generate the working code, intermediate or advanced users can make use of these tags to create custom templates. All template tags have the same basic syntax:

It is important to understand how templates tags works. During code generation, the code generator reads the template, executes the scripts in the template tags, and write the code to the output file.

 

Script Tag

To generate code according to the project settings, there are many script blocks in template. Each script block is enclosed by special script tags.

Syntax:

The scripting language used in the script block is JavaScript as supported by Node.js. To customize template, you need to know JavaScript.

In a script block, you can create variables and constants, use conditional statements, do looping, write functions, everything you can do with JavaScript. You can also access all settings in the project. (See Object Properties for details.) You can generate virtually any code you want.

Example 1

Only generate some code if the table is a view. Here TABLE is a template object and TblType is one of its properties.

Example 2

Add a local function for later use.

 

Output Tag

Output tag outputs a string (which is the generated code), e.g. a literal string, an object property, output by function, etc.

Syntax:

Note The = symbol is immediately after the start tag <#.

Or you can use the built-in write() function:

Example 1 - Output literal string

You can also use JavaScript Template literals, e.g.

Example 2 - Output object property

This line will write the project name in the output file.

Example 3 - Output function result

 

Include() Function

A template usually includes many sub-templates. To include a sub-template, use the built-in include() function:

Example

A sub-template can be in the same folder of the main template or in a sub-folder in the template:

 

 

Also See

Object Properties
Using User Code

 

 ©2002-2025 e.World Technology Ltd. All rights reserved.