Custom Templates & Scripts

All products in our portfolio allow you to use templates to generate your own scripts, HTML code, CSV files, JavaScript source code snippets etc.

Code Your Vision: Custom Templates for Any Scenario

With custom templates, you can create snippets of application code that seamlessly integrate into your projects. Whether it’s a microservice, a front-end component, or a backend module, your custom templates can produce output that match your needs.

Imagine defining a template that generates parts of your application code!

Predefined templates

In the application you can find the Script and Templates tab on the Script modal form with several predefined templates. You can select any item from the dropdown menu and view the generated script.

Luna Modeler

Luna Modeler - custom template-based script

See more screenshots on the What’s new in Luna Modeler 8 page.

Moon Modeler

Moon Modeler - custom templates for generation of custom code.

See more screenshots on the What’s new in Moon Modeler 8 page.

Galaxy Modeler

Galaxy Modeler - custom template-based script

Making modifications and creating new templates

If you want to modify this generated script or generate your own output, whether it is Python code, JavaScript code, etc., just create a copy of one of the predefined templates and start editing this copy or create a completely new template.

How does it work?

All templates are stored in the templates folder, which can be opened directly from the user interface.

Templates toolbar

Each template is composed of two files:

  • One is a *.json document that contains a description of the template and settings for the resulting script.
  • The second file is the *.hbs template, which contains code written in the Handlebars templating system.


  • my-custom-template.json (template definition file)
  • my-custom-template.hbs (template written in Handlebars)

Note: System templates contain “system” in the name. If you see a template named system*.json and system*.hbs, make a copy of the files and do not edit the template files directly. Modification made to system templates will be automatically overwritten when the program starts.

Template definition file

The template definition file is a *.json file and contains the following key-value pairs:

  • fileName – the name of the *.hbs file
  • templateName – the template name that will appear in the user interface (Dropdown)
  • defaultFileSuffix – default suffix of the generated files (files can also be generated with custom suffix. This can be defined in the *.hbs code)
  • singleFileOutput – usually should be set to false, only rarely you will need a single file generated for your project.
  • platforms – an array of platforms. Can be set to [“ALL”] or to a specific platform.
    • Moon Modeler: [“MONGODB”, “MONGOOSE”]
    • Luna Modeler: [“PG”, “MSSQL”, “MARIADB”, “MYSQL”, “SQLITE”]
    • Galaxy Modeler: [“GRAPHQL”]
    • Meteor Modeler: [“SEQUELIZE”]
  • syntaxHighlightingLanguage – use “javascript”, “html”, “sql” or “plaintext”
  • beautify – indicates if white spaces defined in your handlebars template should be preserved or not
  • default – indicates if the template should be selected in UI by default

Example of my-custom-template.json file:

Template JSON file.

Template written in Handlebars

Write your template in Handlebars
It is a popular templating system that is easy to understand and easy to create templates in. You can define template processing conditions for a selected object or for the whole project.

Another important advantage is the possibility to use so-called inline partial templates. Which is a part of a template that can be used multiple times within the main template. In addition, partial templates do not need to be defined in other separate files and so the body of your template can be written within a single *.hbs file.

Example of my-custom-template.hbs file:

Template Handlebars hbs file.

Inline partial templates

In the screenshot above, you can see on lines 5 and 22 the call/reference to the selectStatement which is the inline partial template defined from line 28. You can easily split the template in this way.

Available helpers

In our products we have our own handlebars helpers. These are used for filtering, sorting, comparing, quoting etc. and also to define when a new file should be created.

To create a new file with the default extension (the one specified in the *.json file), use the following:

  {{~> tableColumns }}

To create a new file with a non-default extension, use the following:

{{~#newFileWithSuffix "readme" "txt"~}}
Generated on: {{~timestamp}} by Luna Modeler -

For more details please feel free to contact us.

Available project metadata

  • mainObjects
    • Moon Modeler: collections
    • Luna Modeler: tables, composites (PostgreSQL)
    • Galaxy Modeler: types, inputs, interfaces, unions
    • Meteor Modeler: models
  • otherObjects
    • Moon Modeler: functions, views, other, datatype aliases
    • Luna Modeler: views, procedures, functions, sequences, triggers, enums, domains etc.
  • links
    • Moon Modeler: references
    • Luna Modeler: relationships
    • Galaxy Modeler: references, implements
    • Meteor Modeler: associations
  • lines
  • notes
  • selections
  • selectedObjectId – id of selected object
  • activeDiagramObject – active diagram
  • activeDiagramMainObjects – main objects of the selected diagram
  • activeDiagramOtherObjects – other objects of the selected diagram
  • activeDiagramNotes – notes available on the selected diagram
  • activeDiagramLinks – links available on the selected diagram
  • activeDiagramLines – lines available on the selected diagram
  • itemsOrder – order of generated objects. Should be reversed in case you wish to generate Drop statements.

Repository for custom templates

A GitHub repository for templates is at your disposal. You can contribute your own templates to this repository. In case you need advice or collaboration on template creation, feel free to contact us.


Quick links

Download Buy Now!

Blog Categories
Blog by Platforms