Dashboard > StringTemplate > ... > Syntax > How to Allow Double Angle Brackets as a String
  StringTemplate Log In | Sign Up   View a printable version of the current page.  
  How to Allow Double Angle Brackets as a String
Added by Bernardo Elayda, last edited by Kunle Odutola on Jul 07, 2007  (view change)
Labels: 
(None)

Sometimes the '>>' and/or '<<' delimiters in a StringTemplate group file need to be used as regular strings. This can arise if a StringTemplate is writing out C-code that uses the C operators '<<' or '>>'. For example, consider the follwing StringTemplate in a StringTemplate group file:

group mygroup;

mycode(a,b,c) ::= <<
. . .
d = e >> 3;
f = g << 4;
. . .
>>

If one uses the above template, a run-time error will occur because the shift operators in the statements are being interpreted as the beginning or end of a multiline StringTemplate. Ths solution is to escape each of the angle brackets within the StringTemplate:

group mygroup;

mycode(a,b,c) ::= <<
. . .
d = e \>\> 3;
f = g \<\< 4;
. . .
>>

Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.1 Build:#806 May 06, 2007) - Bug/feature request - Contact Administrators