Telosys news
WebsiteTwitterLinkedInDocumentation
  • Telosys news
  • Version 4.2.0 (2024-November)
  • Version 4.1.1 (2024-January)
  • Version 4.1.0 (2023-August)
    • Model
    • Templates
    • Target languages
    • Model from database
    • Telosys-CLI
  • Version 4.0.0 (2022-April)
  • Version 3.3.0 (2021-July )
    • DSL model annotations
    • DSL model "Tags"
    • Templates features
    • Templates objects
Powered by GitBook
On this page
  • General principles for tags:
  • Example 1 - Simple tag without value :
  • Example 2 - Tag with value :
  1. Version 3.3.0 (2021-July )

DSL model "Tags"

Although Telosys now has many annotations for customizing entities, not all use cases can be predicted in advance and it is not possible to define enough annotations to meet all needs.

This is why the "tags" have been added.

The user can now add information to the attributes of an entity by definig tags of his choice.

Tags are an important advance in the adaptability and flexibility of models.

General principles for tags:

  • a tag starts with the character "#"

  • it is placed in the same block as the annotations (between {and})

  • it can have any name

  • it may or may not have a value

  • in the templates we can check if a tag is present or not and possibly use its value

    • $attrib.hasTag("tagName") Check if "tagName" is defined for $attrib

    • $attrib.tagValue("tagName") Get "tagName" value

Example 1 - Simple tag without value :

Tag "mytag" in entity file :

MyEntity {
  id  : int { @Id } ;

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

Usage in a template :

#if ( $attrib.hasTag("mytag") )  
## do something ...
#end

Example 2 - Tag with value :

Tag "OpenAPIFormat" in entity file :

MyEntity {
  id  : int { @Id } ;

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

Usage in a template :

#if ( $attrib.hasTag("OpenAPIFormat") )  
$attrib.tagValue("OpenAPIFormat")
#end
PreviousDSL model annotationsNextTemplates features

Last updated 3 years ago