Escaping a greater than symbol in the string tool
Velocity doesn't seem to like the > character when testing in the string tool:
#set($echoVal = '"Output Text"')
#set($testPhpText = "<?php echo $echoVal; ?><p>Some HTML.</p><?php morePhp(); ?>")
#set($afterPhp = $_StringTool.substringAfter($testPhpText, "?>"))
output = | $afterPhp |
This give an empty string as a result because there is something happening with the greater than symbol. If I just use a ? it works, or if I test for the whole value of '"<?php echo $echoVal; ?>' as the test it works, but just '?>' makes it fail. Any ideas?
Comments are currently closed for this discussion. You can start a new one.
2 Posted by Eric L. Epps on 06 Jun, 2012 08:41 PM
I don't think your issue is a result of escaping. Looks like it's returning an empty string because there is no string after the second ?>.
Compare the results of this with your results:
Support Staff 3 Posted by Ryan Griffith on 25 Jun, 2012 06:08 PM
Hi Eric,
I was going over some older discussions and noticed this one is still open. Were you able to get your Velocity format working?
Please feel free to let us know if you have any other questions.
Thanks.
4 Posted by James White on 26 Jun, 2012 11:56 AM
All Eric number 2 does is give an example of a text string on which $_StringTool.substringAfter does HAPPEN to work, he gives no mechanism for making the correct answer appear on Eric number 1's text. You can easily see that with the following which uses both of their strings and a "sample" string without a ">" (though it may be the "?>" pair that is the issue, I don't know for sure).
5 Posted by James White on 26 Jun, 2012 01:46 PM
Hey moderator, I guess cut and paste doesn't correctly represent what is entered. This one will do the code as a file.
All Eric number 2 does is give an example of a text string on which $_StringTool.substringAfter does HAPPEN to work, he gives no mechanism for making the correct answer appear on Eric number 1's text. You can easily see that with the following which uses both of their strings and a "sample" string without a ">" (though it may be the "?>" pair that is the issue, I don't know for sure).
Support Staff 6 Posted by Ryan Griffith on 26 Jun, 2012 04:06 PM
Hi James,
Thank you for the heads up, I updated your original post to surround your code in a code block. For future code snippets, feel free to surround your code with @@@ (before and after) to avoid any formatting complications.
Ryan Griffith closed this discussion on 17 Jul, 2012 06:50 PM.