aboutsummaryrefslogtreecommitdiff
path: root/velocity-engine-core/src/test/resources/templates/escape2.vm
blob: 1ba83a798707afd43490e00802dd19a784097a56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#*
@test escape2.vm

More interesting cases...

This template is used for Velocity regression testing.
If you alter this template make sure you change the
corresponding comparison file so that the regression
test doesn't fail incorrectly.

*#
--- Schmoo ---

These are not in the context, so they should render as they are here (schmoo).
$foo
\$foo
\\$foo

\#woogie
\\#woogie
\\\#woogie

Now put $foo in the context :
#set($foo = "bar")
\$foo = $foo
\\\$foo =\\$foo
\\\\\$foo =\\\\$foo

As we increase the number of \'s, we alternate renderings :
$foo
\$foo
\\$foo
\\\$foo
\\\\$foo

--- Pluggable Directives ----

We are doing an \#include("test.txt"), starting with 0 '\' preceeding :

#include("test.txt")
\#include("test.txt")
\\#include("test.txt")
\\\#include("test.txt")
\\\\#include("test.txt")

Now, foreach is a PD.  Escape the first one, and then not the second so it
renders.  The third and fourth examples show the single 'unpleasantry' about this.  The \
is only an escape when 'touching' VTL, otherwise, it's just schmoo.

\#foreach(

\\#foreach($a in $stringarray) $a \\#end

\\#foreach($a in $stringarray) $a \ \\#end

\\#foreach($a in $stringarray)$a\ \\#end


--- Control Structures ----

First should be escaped...
\#if(true) hi \#end

This isn't.  Note then that it has to render the \\ as a \ because it's stuck to the VTL

\\#if(true) hi \\#end

\\#if(true) hi #end

And so forth...
\\\#if(true) hi \\\#end

\\\\#if(true) hi \\\\#end

And more...

\#if(true)
	hi
\#else
	there
\#end

\\#if(true)
	hi
\\#else
	there
\\#end

\\\#if(true)
	hi
\\\#else
	there
\\\#end

\\#if(false)
	hi
\\#elseif(true)
	there
\\#end

\\\#if(false)
	hi
\\\#elseif(true)
	there
\\\#end

## testing combinations like #$foo

#$foo1
\#$foo1
#${foo1}
\#$${foo1}
#set($foo1 = "C0C0C0")
#$foo1
\#$foo1
#${foo1}
\#$${foo1}
#\$${foo1}

## and wacky stuff that are not references, but
## because of the MORE tokens, get screwed up

$(QUERY_STRING{forumid})
\$(QUERY_STRING{forumid})
\\$(QUERY_STRING{forumid})

##
##  and just slashes....
##

\
\\
\\\
\\\\
\\\\\
\\\\\\
\\\\\\\
\\\\\\\\