[stringtemplate-interest] formal arg checking
Nate
misc at n4te.com
Thu Apr 26 12:09:53 PDT 2007
I assume you are proposing this...
$if (errorMessage)$
$table(emptyMessage=errorMessage)$
$else$
$table(emptyMessage="The list is empty.")$
$endif$
While this would solve my specific scenario, formal argument checking is
still flawed. I should be able to use undefined attributes when applying
a template, like this...
$table(emptyMessage={$errorMessage; null="The list is empty."$})$
When "errorMessage" is not defined, that code currently throws an error
saying that the attribute "errorMessage" is not a valid formal argument
for the "table" template.
Also, the workaround to use an IF statement is not very elegant for more
complex scenarios because it duplicates the template call. Eg...
$if (errorMessage)$
$table(
emptyMessage=errorMessage,
rows={
Lots of HTML here.
}
)$
$else$
$table(
emptyMessage="The list is empty.",
rows={
Lots of HTML here.
}
)$
$endif$
Hope you have fun on your trip!
-Nate
Terence Parr wrote:
> On Apr 26, 2007, at 11:01 AM, Nate wrote:
>
>> In this particular case, the "table" template displays a table of
>> data.
>> If no data is specified, it displays an error message from the
>> controller OR a message ("The list is empty.") from the template. If
>> there is no error, the message comes from the template, not from the
>> controller.
>
> Can't a simple IF fix this in the template?
>
> Ter
> PS i'm leaving now for the airport. gone 4 days...
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
More information about the stringtemplate-interest
mailing list