Newer
Older
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8 />
<title>{$title}</title>
<!-- this link will be substituted with the right path : href="THEMES/acid/style.css" -->
<link href="style.css" type="text/css" rel="stylesheet" >
</head>
<body>
<!-- this img will be substituted with the right path : src="THEMES/acid/images.gif" -->
<div id="logo"><a href="http://www.raintpl.com"><img src="img/logo.gif"></a></div>
<!-- content -->
<div id="content">
<h2>Variable example</h2>
<div class="layout">
<h3>Variable example</h3>
{* all code between noparse tags is not compiled *}
<tt>variable {noparse}{$variable}{/noparse} = <b>{$variable}</b></tt>
<br/><br/>
<h3>Variable assignment</h3>
<tt>assignment {$number=10} and print {$number}</tt>
<br/><br/>
<h3>Operation with strings</h3>
<tt>
{$variable . $number}<br/>
{$number + 20}
</tt>
<br/><br/>
<h3>Variable Modifiers</h3>
<tt>
{$variable|substr:0,7}<br/>
a modifier on string: {"hello world"|strtoupper}
</tt>
<br/><br/>
<h3>Global variables</h3>
<tt>The variable is declared as global into the PHP {$GLOBALS.global_variable}</tt>
<br/><br/>
<h3>Show all declared variables</h3>
To show all declared variable use {noparse}{$template_info}{/noparse}.<br/><br/>
<tt>
{$template_info}
</tt>
<br/><br/>
</div>
<h2>Constants</h2>
<div class="layout">
<h3>Constant</h3>
<tt>Constant: {#true#}</tt>
<br/><br/>
<h3>Modier on constant as follow</h3>
<tt>Negation of false is true: {PHP_VERSION|round}</tt>
</div>
<h2>Loop example</h2>
<div class="layout">
<h3>Simple loop example</h3>
<tt>
<ul>
{loop="week"}
<li>{$key} = {$value}</li>
{/loop}
</ul>
</tt>
<br/><br/>
<h3>Loop example with associative array</h3>
<tt>
<ul>
<li>ID _ Name _ Color</li>
{loop="user"}
<li class="color{$counter%2+1}">{$key}) - {$value.name|strtoupper} - {$value.color}</li>
{/loop}
</ul>
</tt>
<br/><br/>
<h3>Loop an empty array</h3>
<tt>
<ul>
{loop="empty_array"}
<li class="color{$counter%2+1}">{$key}) - {$value.name} - {$value.color}</li>
{else}
<b>The array is empty</b>
{/loop}
</ul>
</tt>
</div>
<h2>If Example</h2>
<div class="layout">
<h3>simple if example</h3>
<tt>
{if="$number==10"}OK!
{else}NO!{/if}
</tt>
<br/><br/>
<h3>example of if, elseif, else example</h3>
<tt>
{if="substr($variable,0,1)=='A'"}First character is A
{elseif="substr($variable,0,1)=='B'"}First character is B
{else}First character of variable is not A neither B
{/if}
</tt>
<br/><br/>
<h3>use of ? : operator (number==10?'OK!':'no')</h3>
You can also use the ? operator instead of if
<tt>{$number==10? 'OK!' : 'no'}</tt>
</div>
<h2>Include Example</h2>
<div class="layout">
<h3>Example of include file</h3>
<tt>{include="test"}</tt>
</div>
<h2>Functions</h2>
<div class="layout">
<h3>Example of function: ucfirst(strtolower($title))</h3>
<tt>{function="ucfirst(strtolower($title))"}</tt>
</div>
<h2>Path Replace (WYSIWYG)</h2>
<div class="layout">
<h3>WYSIWYG</h3>
RainTPL replaces relative paths of images, css and links automatically with the correct server paths.
<br/><br/>
<h3>Path replace on relative path of image</h3>
into the template the image is wrote as:
<code><img src="img/logo.gif" alt="logo"/></code>
in the compiled template the path is replaced with the correct path <b>tpl/img/logo.gif</b>:<br/>
<img src="img/logo.gif" alt="logo"/>
<br/><br/><br/>
<a href="javascript:alert('Javascript is not replaced');">RainTpl is javascript friendly</a>
<b>Absolute paths and path ending with # are not replaced</b>
<br/><br/>For more info read the documentation:
<tt><a href="http://www.raintpl.com/Documentation/Documentation-for-web-designers/WYSIWYG/">http://www.raintpl.com/Documentation/Documentation-for-web-designers/WYSIWYG/</a></tt>
</div>
</div>
<div id="footer">{$copyright}</div>
</body>
</html>