Telosys doc
WebsiteTwitterLinkedInNews
  • Telosys documentation
  • Telosys CLI
    • Installation on Linux
    • Installation on Windows
    • CLI configuration
    • CLI commands
    • Getting started
  • Telosys with VSCode
    • Extension installation
    • VSCode settings
    • Telosys terminal in VSCode
    • Telosys editor configuration
  • Telosys with JetBrains IDE
  • Project configuration
  • Project variables
  • Project databases
  • Models and entities
    • Model structure
    • Entity
    • Attribute / Link
    • Annotations
    • Tags
    • Examples
    • Model creation
    • Model installation
    • Models management
  • Bundles of templates
    • Bundle structure
    • Bundle creation
    • Bundles installation
    • Bundles management
    • Velocity language
    • Velocity directives
    • Velocity object types
    • Telosys directives
    • Telosys variables
    • Telosys objects
    • Code snippets
  • Code generation
    • "gen" command
    • "genb" command
  • Target languages
    • C++
    • C#
    • Golang
    • Java
    • JavaScript
    • Kotlin
    • PHP
    • Python
    • Scala
    • TypeScript
  • Target databases (SQL)
    • Predefined rules
    • Specific rules
    • Type size and precision
  • Telosys with Git
    • GitHub usage
    • Install with Git
    • Publish with Git
  • Support the project
  • How to contribute
  • Sponsors
  • IDE and editors
  • Telosys 3 Eclipse plugin
    • Eclipse plugin installation
    • Eclipse customization
    • Telosys 3 database model
Powered by GitBook
On this page
  • Set tags in model
  • Use tags in templates
  1. Models and entities

Tags

As Telosys aims to provide highly customizable models (and predefined annotations are usually not sufficient to handle all special cases) in version 3.3.0 "tags" have been added for attributes and since version 4.0.0 they can be used everywhere (entity, attribute and link).

Tags are a very simple way to easily customize your models by adding as much additional information as you want.

Set tags in model

Each entity, attribute or link can have 0 to N tags.

Like annotations, tags provide additional information usable during the code generation. But, unlike annotations, tags do not have predefined names. The user can define as many tags as he wants.

A tag is any name starting with "#" and optionally having a value. If the tag has a value then the value is defined between "(" and ")".

Examples of tags :

MyEntity {
id  : int { @Id } ;

// tag "mytag" (without value) :
comment : string { #mytag } ;

// tag "OpenAPIFormat" with value :
val : long  { #OpenAPIFormat(int64) } ;

}

Use tags in templates

In a template you can define conditions based on the presence (or absence) of a tag and you can retrieve the value of a tag (with default value if necessary).

To do this, use the following syntax:

  • $x.hasTag("tagName")

  • $x.tagValue("tagName")

  • $x.tagValue("tagName", "defaultValue")

  • $x.tagValueAsBoolean("tagName", true/false)

  • $x.tagValueAsInt("tagName", 123)

Example : check tag presence and use its value if present

#if ( $attrib.hasTag("OpenAPIFormat") )  
$attrib.tagValue("OpenAPIFormat")
#end
PreviousAnnotationsNextExamples

Last updated 5 months ago

See reference guide for detailed information (objects $entity, $attribute and $link).

Telosys objects