[#tab]body[/#tab] or [#tab(tabString)]body[/#tab] or [#tab(tabString, numberOfTabs)]body[/#tab]
where:
"\t"
).The tab directive is used to right shift using a tab character a section of a template.
It captures the output generated inside its body (i.e. between its start-tag and end-tag),
and add some tab characters (one '\t'
by default, or the specified tabString)
at the beginning of each new line.
This directive enables to design scripts and text templates to be included without having to know where they will be inserted (i.e. without having to know how many tabs they should put at the beginning of each line).
This template generates a Javadoc:
[#package com.mycompany.example] [#template Javadoc(doc : String)] /** * ${doc} */ [/#template]
We include this Javadoc at different levels in a template that generates a Java file:
[#package com.mycompany.example] [#template GenerateJavaFile(class : uml21.Class)] [#file]${class.name}.java[/#file] [#-- inserts the Javadoc, without formatting --] [#include Javadoc("class documentation")] public class ${class.name} { [#-- this will shift right the evaluated javadoc --] [#tab][#include Javadoc("toString documentation")][/#tab] public String toString() { return super.toString(); } } [/#template]
The above code would produce an output similar to the following:
/** * class documentation */ public class Account { /** * toString documentation */ public String toString() { return super.toString(); } }