JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
make metaform tarballs come with install doc
[wfpl.git] / doc / template.php.txt
1         First you have some globally accessible array of key->value pairs which contain the data to be entered into templates
2
3         Then you have some template files
4
5 tem_set($key, $value)
6 tem_get($key)
7 tem_run($file/template)
8 tem_echo($file/template) { echo tem_run($file); }
9
10 This should work for simple templates such as:  foo: '~foo~'
11
12
13         It gets trickier when you have bits in your template that need to be repeated
14         (with different tags each time) and others perhaps not displayed at all.
15
16         foobar.html:
17
18 <table>
19 <tr><th>foo</th><th>bar</th></tr>
20 <!--~foobar_row {~--><tr><td>~foo~</td><td><input value="~bar~"></tr><!--~}~-->
21 </table>
22
23 tem_load('foobar.html');
24
25                 
26                 the main template (with the sub-templates like foobar_row replaced with a single tag ie:
27
28 <table>
29 <tr><th>foo</th><th>bar</th></tr>
30 ~foobar_row~
31 </table>
32
33         Main data structure:
34                 key/value pairs
35                 template file (if template string is empty, it will be read from here)
36                 template string
37                 sub templates:
38                         key: foobar_row
39                         value: <tr><td>~foo.....html~</td><td><input value="~bar.attr~"></tr>