{"id":786,"date":"2014-07-02T19:24:10","date_gmt":"2014-07-03T02:24:10","guid":{"rendered":"https:\/\/blogs.plm.automation.siemens.com\/t5\/Polarion-Blog\/Tech-Tips-amp-Tricks-tips-to-solve-unruly-Velocity-problems\/ba-p\/380864"},"modified":"2026-03-26T05:30:57","modified_gmt":"2026-03-26T09:30:57","slug":"tech-tips-tricks-tips-to-solve-unruly-velocity-problems","status":"publish","type":"post","link":"https:\/\/blogs.sw.siemens.com\/polarion\/tech-tips-tricks-tips-to-solve-unruly-velocity-problems\/","title":{"rendered":"Tech Tips &#038; Tricks: tips to solve unruly Velocity problems"},"content":{"rendered":"<p>Welcome to another installment in our series of tips and tricks from the Polarion Software Technical Support team, in which we share solutions we provided to customers for real-world use cases that. The same tips might help you too, or others on your team. Let&#8217;s look today at a couple of things with Velocity than can be frustrating until you know the trick.&nbsp;<!--more--><br \/>\n<H2>Use Case<\/H2><br \/>\nGet rid of the text line when <CODE>variable<CODE> is not defined in Velocity.<\/CODE><\/CODE><br \/>\n<H2>Solution<\/H2><br \/>\nUse <CODE style=\"font-weight: bold;\">$!variable<CODE><\/CODE><\/CODE><\/p>\n<p>The difference is what it does when &#8216;variable&#8217; is not defined. In that case &#8216;$&#8217; renders the whole line as if it were plain text (which is not what you want in most cases), whereas &#8216;$&#8217; outputs nothing. So using &#8216;$&#8217; is usually a safer option.<br \/>\n<PRE style=\"line-height: normal; border: 1px dashed #999; background-color: #f8f8f8; padding: 10px;\">#set($y = $null)<br \/>\nOutput of $!y is:<br \/>\nOutput of $y is: $y<\/PRE><br \/>\n<H2>Use Case<\/H2><br \/>\nEscaped special character (&#8220;) doesn&#8217;t work with Velocity.<br \/>\n<H2>Solution<\/H2><br \/>\nWe worked around the problem with quotes by saving the double quote character in to a variable x. (Please note the syntax &#8216;&nbsp;&#8221;&nbsp;&#8216; &#8211; without spaces).<br \/>\n<PRE style=\"line-height: normal; border: 1px dashed #999; background-color: #f8f8f8; padding: 10px;\">#set($test = &#8220;WI-17&#8221;)<br \/>\n#set($x = &#8216;&#8221;&#8216;)<br \/>\n#set($query = &#8220;id:${x}${test}${x}&#8221;)<\/PRE><br \/>\nOutput is: <STRONG>id:&#8221;WI-17&#8243;<\/STRONG><\/p>\n<p><HR \/><\/p>\n<p><EM>Jiri Jandl is a Senior Support Engineer with Polarion Software&#8217;s European tech support team. He is based in Prague, Czech Republic.<\/EM><\/p>\n<p><HR \/><br \/>\n<P style=\"text-align: center;\"><A href=\"http:\/\/www.polarion.com\/techsupport\/index.php#support-level\" rel=\"nofollow noopener noreferrer\"><IMG class=\"alignnone size-full wp-image-5839\" src=\"http:\/\/community.plm.automation.siemens.com\/legacyfs\/online\/siemensplm_blogs\/2014\/06\/polarion-silver-gold-support.jpg\" alt=\"Banner: It's all about solutions - Polarion Silver and Gold Support\" width=\"700\" height=\"150\" \/><\/A><\/P><br \/>\n<P style=\"text-align: left;\"><\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome to another installment in our series of tips and tricks from the Polarion Software Technical Support team, in which we share solutions we provided to customers for real-world use cases that. &#8230;<\/p>\n","protected":false},"author":54129,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spanish_translation":"","french_translation":"","german_translation":"","italian_translation":"","polish_translation":"","japanese_translation":"","chinese_translation":"","footnotes":""},"categories":[1],"tags":[],"industry":[],"product":[],"coauthors":[],"class_list":["post-786","post","type-post","status-publish","format-standard","hentry","category-news"],"_links":{"self":[{"href":"https:\/\/blogs.sw.siemens.com\/polarion\/wp-json\/wp\/v2\/posts\/786","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.sw.siemens.com\/polarion\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.sw.siemens.com\/polarion\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/polarion\/wp-json\/wp\/v2\/users\/54129"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/polarion\/wp-json\/wp\/v2\/comments?post=786"}],"version-history":[{"count":1,"href":"https:\/\/blogs.sw.siemens.com\/polarion\/wp-json\/wp\/v2\/posts\/786\/revisions"}],"predecessor-version":[{"id":787,"href":"https:\/\/blogs.sw.siemens.com\/polarion\/wp-json\/wp\/v2\/posts\/786\/revisions\/787"}],"wp:attachment":[{"href":"https:\/\/blogs.sw.siemens.com\/polarion\/wp-json\/wp\/v2\/media?parent=786"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/polarion\/wp-json\/wp\/v2\/categories?post=786"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/polarion\/wp-json\/wp\/v2\/tags?post=786"},{"taxonomy":"industry","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/polarion\/wp-json\/wp\/v2\/industry?post=786"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/polarion\/wp-json\/wp\/v2\/product?post=786"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/polarion\/wp-json\/wp\/v2\/coauthors?post=786"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}