Putting quotes around dynamically generated text in Velocity Templates in Java
<p>I am trying to enclose a dynamically generated text in quotes in a Velocity Template. The dynamically generated text can be empty also, so the quotes need not be shown. But if the text is not empty, it needs to be enclosed in quotes.</p>

<p>Can this be achieved using Velocity templates that when the text is empty, the quotes around it disappear?</p>

<p>My code is as follows:</p>

<pre><code>#if ($messageFromSender == "") &lt;i&gt;&lt;/i&gt; 
#else &lt;i&gt;&amp;quot;$!{messageFromSender}&amp;quot;&lt;/i&gt;
</code></pre>

<p>This is the Exception that I get:</p>

<pre><code>org.apache.velocity.exception.ParseErrorException: Encountered "&lt;EOF&gt;"
</code></pre>

<p>Thanks in advance.</p>