[stringtemplate-interest] Conditional access to Map attribute

Tommy C. Li tommycli at ucla.edu
Wed Jan 13 22:31:18 PST 2010


Here's basically what I want to do:

   $if(metadata.description)$
     <br />
     $metadata.description$
   $endif$

Where "metadata" is a Map passed in. "metadata" may or may not contain
"description" as a key. If it does not, I hope to have it print nothing.

Right now I get:

Class com.keepword.render.MyJCL$$anon$1 has no such attribute:
description in template context [short]
java.lang.NoSuchFieldException: description

What's the proper way to accomplish this in ST?

Tommy



More information about the stringtemplate-interest mailing list