]> mj.ucw.cz Git - temple.git/blob - test
Moved template variables and functions to a separate package.
[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) { print "$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 (result will be discarded):
33 @print("One", "Two", "Three\n")
34
35 @# Or do the same with parameters running up to the end of the line:
36 @print "Four", "Five", "Six\n"
37
38 @# There are also some conditionals (you can use any perl expressions):
39 @if 1
40 @if 0
41 one
42 @elif 0
43 two
44 @elif 1
45 three
46 @fi
47 @else
48 four
49 @fi
50
51 @# Or you can use the parenthesized form:
52 @if(0)ONE@else()TWO@fi()THREE
53
54 @# To include another file (and possibly change some variables), use:
55 @include("test2", "a" => "HOWDY", "b" => "HULLO", "c" => "AHOY")
56 @include "test2", "a" => "howdy", "b" => "hullo", "c" => "ahoy"
57
58 @# And to load a perl file:
59 @load "test3"
60
61 @# This one is tricky:
62 @print("z\n", <<EOF
63 a
64 b
65 c
66 EOF
67 )
68
69 @# We are done:
70 Finis.