1:
2: Calling func1: @func1("arg1", "arg two")
3:
4: Calling func2(3): @func2(@func3())
5:
6: @set("foo", "bar")
7: foo="@get("foo")"
8: bar="@get("bar")"
9: @set("foo", "blab")
10: foo="@get("foo")"
11:
12: @set("foo", @error_test("this is", "a test"))
13:
14: HTML Escaping "!@#$%^&*()}{][-|\"';:?></.,~`" --> @htmlencode("!@#$%^&*()}{][-|\\\"';:?></.,~`")
15:
16: URL Encoding "!@#$%^&*()}{][-|\"';:?></.,~`" --> @urlencode("!@#$%^&*()}{][-|\\\"';:?></.,~`")
17:
18: An at sign looks like this: ``@@''
19:
20: Should@if(@not(@or("0", "not", "nope", @and("1", "2", "3"))))n't@endif see this.
21: Should@if(@and("0", @or("0", "1")))n't@endif see this.
22:
23: @@and("0", "0") = @and("0", "0")
24: @@and("0", "1") = @and("0", "1")
25: @@and("1", "0") = @and("1", "0")
26: @@and("1", "1") = @and("1", "1")
27: @@or("0", "0") = @or("0", "0")
28: @@or("0", "1") = @or("0", "1")
29: @@or("1", "0") = @or("1", "0")
30: @@or("1", "1") = @or("1", "1")
31:
32: @if(@not(@equal("abc", "def")))Should@else()Should not@endif see this.
33:
34: @parse error()
35: @parseerror(()
36: @parseerror(@okfunc(@okfunc(), loopindex()), @bad func())
37: @parseerror("bogus string\")
38: @parseerror("bogus string
39:
40: @foo_bar()
41: @foobar("abc")
42: @janfu("\x41\x42\x43")
43: @foobar("123",@janfu("\x41\x42\x43"))
44:
45: @loop("2")@loop("3")This is iteration @loopindex("1").@eval("@loopindex(\"0\")").
46: @endloop
47: @endloop
48:
49: @eval("just some random data here.")
50:
51: @loop("3")@loopindex()..@endloop..done
52: @eval("what follows was @@eval()'d:\nloop: @loop(\"3\")@loopindex()..@endloop..done")
53:
54: @error("error string")
55:
56: MARKER C
57:
58: @if ("0")
59: @elif ("2")
60: @loop ("3")
61: @endloop
62: @elif ("3")
63: @endif
64:
65: MARKER D
66:
67: @loop("3")
68: @if (@equal(@loopindex(), "0"))
69: First iteration
70: @elif (@equal(@loopindex(), "1"))
71: Second iteration
72: @elif (@equal(@loopindex(), "2"))
73: Last iteration
74: @else
75: Unexpected loopindex ``@loopindex()''
76: @endif
77: @endloop
78:
79: MARKER E
80:
81: This should be "abc": @eval("\"@cat(\"a\\x62c\")\"")
82: @if("0") should not see this
83: @if ( @equal( "a", "\x61" ) )
84: 1: should not see this
85: @else
86: 2: should not see this
87: @endif
88: @elif (@equal("abc", @eval("ab\x63")))
89: 3: should see this
90: @if (@equal( "a", "\x61" ))
91: 4: should see this
92: @else
93: 5: should not see this
94: @endif
95: @elif (@equal("def", "def"))
96: 6: should not see this
97: @else
98: 7: should not see this
99: @endif
100:
101:
102: @ notfunc()
103:
104: @set("foo", "4")
105: @while(@get("foo"))
106: Foo is @get("foo")
107: @if(@equal(@get("foo"), "4"))
108: @set("foo", "3")
109: @continue
110: @endif
111: @if(@equal(@get("foo"), "3"))
112: @set("foo", "2")
113: @continue
114: @endif
115: @if(@equal(@get("foo"), "2"))
116: @set("foo", "1")
117: @break
118: @endif
119: @if(@equal(@get("foo"), "1"))
120: Shouldn't see this
121: @endif
122: @set("foo", "notbar")
123: Shouldn't see this
124: @endwhile
125:
126: @define("dfunc")
127: Number of arguments is @get("argc")
128: @loop(@get("argc"))Argument #@loopindex() is "@get(@cat("arg", @loopindex()))".
129: @endloop
130: @enddef
131:
132: @invoke()
133: @set("argc", "1")
134: @invoke()
135: @set("arg0", "unknown_function")
136: @invoke()
137: @set("argc", "3")
138: @set("arg0", "dfunc")
139: @set("arg1", "1st argument")
140: @set("arg2", "2nd argument")
141: @invoke()
142:
143: 23 / 4 = @div("23", "4")
144: 123 / 0 = @div("123", "0")
145: -12 % 5 = @div("-12", "5")
146:
147: @dfunc("foo", "bar", "jan")
148:
149: @eval(@cat("@define(\"dfunc\")Another def'n of @get(\"arg0\")",
150: " (@get(\"argc\") args)\n@enddef"))
151:
152: @dfunc("foo", "jan")
153:
154: @define("recursive")@recursive(@get("arg1"), @get("arg2"))@enddef
155: @recursive("foo", "bar")
156:
157: last line
158:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>