StringTemplate 4 set condition from java
<p>How to set ST4 condition from Java?</p>

<p>I have following ST4 template</p>

<pre><code>templateExample(param) ::= &lt;&lt;
$if (condition)$
&lt;ul&gt;&lt;li&gt;$param$ is true&lt;/li&gt;&lt;/ul&gt;
$else$
&lt;ul&gt;&lt;li&gt;$param$ is false&lt;/li&gt;&lt;/ul&gt;
$endif$
&gt;&gt;
</code></pre>

<p>While the main class is</p>

<pre><code>public static void main(String[] args) {
        final STGroup stGroup = new STGroupFile("exampleTemplate.stg", '$', '$');
        stGroup.registerRenderer(String.class, new StringRenderer());

        final ST templateExample = stGroup.getInstanceOf("templateExample");
        templateExample.add("param", "Hello World");
        templateExample.add("condition", true);

        System.out.println(templateExample.render());
    }
</code></pre>

<p>However when i run the code, following error raised : </p>

<pre><code>Exception in thread "main" java.lang.IllegalArgumentException: no such attribute: condition
    at org.stringtemplate.v4.ST.add(ST.java:226)
    at com.cupidocreative.main.StringTemplateSandboxMain.main(StringTemplateSandboxMain.java:16)
</code></pre>

<p>How to set the "condition" from my java class?
Thanks in advance</p>