]> mj.ucw.cz Git - temple.git/blob - test
Updated the test cases.
[temple.git] / test
1 @# A test program for Temple
2 @# starts with a couple of comments
3
4 @# The language is very simple -- everything except the "@" character
5 @# gets passed to the output verbatim:
6 Verbatim.
7
8 @# The "@" starts a control sequence. Arguments of control sequences
9 @# are either everything to the end of the current line (as in case
10 @# of the comment command you are looking at) balanced parenthesized
11 @# string.
12 @#
13
14 @# If we want to ignore and end of line character, just prefix it by "@":
15 This line @
16 won't be broken@
17 .
18
19 @# If you want to write the "@" character, just write it twice:
20 @@
21
22 @# You can embed any perl code in your text:
23 @[foreach $x (1..10) { out "$x "; } ]
24
25 @# Or if you use @{...}, then the value of the last expression executed
26 @# gets printed automatically:
27 @{"1+2+3 = " . (1+2+3)}
28
29 @# You can also interpolate perl variables by using @$variable:
30 I was run as @$0.
31
32 @# It is possible to call any perl functions
33 @# (any result other than undef will be printed automatically)
34 @# Use `out' to write to the output stream
35 @out("One", "Two", "Three\n")
36
37 @# Or do the same with parameters running up to the end of the line:
38 @out "Four", "Five", "Six\n"
39
40 @# There are also some conditionals (you can use any perl expressions):
41 @if 1
42 @if 0
43 one
44 @elif 0
45 two
46 @elif 1
47 three
48 @fi
49 @else
50 four
51 @fi
52
53 @# Or you can use the parenthesized form:
54 @if(0)ONE@else()TWO@fi()THREE
55
56 @# To include another file (and possibly change some variables), use:
57 @include("test2", "a" => "HOWDY", "b" => "HULLO", "c" => "AHOY")
58 @include "test2", "a" => "howdy", "b" => "hullo", "c" => "ahoy"
59
60 @# And to load a perl file:
61 @load "test3"
62
63 @# This one is tricky:
64 @out("z\n", <<EOF
65 a
66 b
67 c
68 EOF
69 )
70
71 @# We are done:
72 Finis.