1#* 2@test escape2.vm 3 4More interesting cases... 5 6This template is used for Velocity regression testing. 7If you alter this template make sure you change the 8corresponding comparison file so that the regression 9test doesn't fail incorrectly. 10 11*# 12--- Schmoo --- 13 14These are not in the context, so they should render as they are here (schmoo). 15$foo 16\$foo 17\\$foo 18 19\#woogie 20\\#woogie 21\\\#woogie 22 23Now put $foo in the context : 24#set($foo = "bar") 25\$foo = $foo 26\\\$foo =\\$foo 27\\\\\$foo =\\\\$foo 28 29As we increase the number of \'s, we alternate renderings : 30$foo 31\$foo 32\\$foo 33\\\$foo 34\\\\$foo 35 36--- Pluggable Directives ---- 37 38We are doing an \#include("test.txt"), starting with 0 '\' preceeding : 39 40#include("test.txt") 41\#include("test.txt") 42\\#include("test.txt") 43\\\#include("test.txt") 44\\\\#include("test.txt") 45 46Now, foreach is a PD. Escape the first one, and then not the second so it 47renders. The third and fourth examples show the single 'unpleasantry' about this. The \ 48is only an escape when 'touching' VTL, otherwise, it's just schmoo. 49 50\#foreach( 51 52\\#foreach($a in $stringarray) $a \\#end 53 54\\#foreach($a in $stringarray) $a \ \\#end 55 56\\#foreach($a in $stringarray)$a\ \\#end 57 58 59--- Control Structures ---- 60 61First should be escaped... 62\#if(true) hi \#end 63 64This isn't. Note then that it has to render the \\ as a \ because it's stuck to the VTL 65 66\\#if(true) hi \\#end 67 68\\#if(true) hi #end 69 70And so forth... 71\\\#if(true) hi \\\#end 72 73\\\\#if(true) hi \\\\#end 74 75And more... 76 77\#if(true) 78 hi 79\#else 80 there 81\#end 82 83\\#if(true) 84 hi 85\\#else 86 there 87\\#end 88 89\\\#if(true) 90 hi 91\\\#else 92 there 93\\\#end 94 95\\#if(false) 96 hi 97\\#elseif(true) 98 there 99\\#end 100 101\\\#if(false) 102 hi 103\\\#elseif(true) 104 there 105\\\#end 106 107## testing combinations like #$foo 108 109#$foo1 110\#$foo1 111#${foo1} 112\#$${foo1} 113#set($foo1 = "C0C0C0") 114#$foo1 115\#$foo1 116#${foo1} 117\#$${foo1} 118#\$${foo1} 119 120## and wacky stuff that are not references, but 121## because of the MORE tokens, get screwed up 122 123$(QUERY_STRING{forumid}) 124\$(QUERY_STRING{forumid}) 125\\$(QUERY_STRING{forumid}) 126 127## 128## and just slashes.... 129## 130 131\ 132\\ 133\\\ 134\\\\ 135\\\\\ 136\\\\\\ 137\\\\\\\ 138\\\\\\\\ 139