Java Reference
In-Depth Information
«
LET
expression
AS
varName»
. . .
«
ENDLET
»
Statements using the variable are nested within the block. For example, if we
wanted to use a
«LET»
statement for our Topic CSV filename, we could refactor
our template as shown next. When accessing
«LET»
or metamodel elements
within a body, simply place the name within guillemets, as in
«fileName»
.
«
LET
title + "-topics.csv"
AS
fileName»
«
FILE
fileName TOPIC_OUTLET-»
«name»,«start»,«end»
«
ENDFILE
»
«
ENDLET
»
14.1.10 ERROR
You can terminate the execution of a template by inserting an
«ERROR»
state-
ment. The
expression
will be used as the message of an
XpandException
,
which is thrown if the
«ERROR»
is processed. Note that it's typically best to val-
idate input model elements before executing templates, so using the
«ERROR»
statement is rarely required. This is the general syntax:
«
ERROR
expression»
This simple example reports when the passed
Map
class has no title set:
«
DEFINE
Main
FOR
Map»
«
IF
title ==
null
|| title == ''-»
«
ERROR
'No title'»
«
ELSE
»
...
«
ENDIF
»
«
ENDDEFINE
»
14.1.11 REM
Comments can be added to templates to provide documentation using the
«REM»
statement.
«REM»
tags cannot be nested. They follow this general syntax:
«
REM
»Text comment here...«
ENDREM
»
Search WWH ::
Custom Search