Happy happy joy joy, www.infodrom.ffis.de is up!
[infodrom.org/www.infodrom.org] / src / projects / cgilib / cgivar.wml
1 #include <infodrom.style>
2 #include <projects.style>
3
4 <projectpg project="cgilib" maxcontrib=5>
5
6 <h3>The CGI Variable library</h3>
7
8   This library intends to help people maintaining web sites with
9   included CGI-support, e.g. as connection to a database or something
10   else. <p>
11
12   The library helps you to divide between design and content.  Thus
13   the person who works on web design does not need to know about
14   programming and the person who does the actual cgi programming does
15   not need to know anything about HTML and web design. <p>
16
17   The past has shown that often these people only want or can work on
18   one of the two issues but not on both.  However, you'll need to
19   understand that design and content are divided and the person
20   writing the CGI program does not need (or does now want) to munch
21   with HTML. <p>
22
23 <h3>Supported languages</h3>
24
25   Currently only Perl is supported.  Support for C is urgently
26   required, though. <p>
27
28 <h3>Installation</h3>
29
30   Place the file cgivar.pl in /usr/local/lib/site_perl/ or whereever
31   your Perl installation expects additional .pl files. <p>
32
33 <h3>Usage</h3>
34
35   To add cgivar support to your programm, simply add the following
36   line at the top of it: <p>
37
38 <pre>
39     require 'cgivar.pl';                # HTML-Parser
40 </pre>
41   
42
43   You will have to open the template file first and pass an arbitrary
44   amount of (name,value) pairs to the display routine.  The template
45   is loaded with: <p>
46
47 <pre>
48     &cgivar_load ($template);
49 </pre>
50
51   Where $template refers to the full path to the template.  You may
52   call your template foo.html in order to let Editors (preferred:
53   Emacs) recognize it as HTML file.  This will make the library
54   evaluate the template and store it in its internal data structures.
55   You may load more than one template at the same time. <p>
56
57   If that's done you may now fill a hash with (name,value) pairs such
58   as: <p>
59
60 <pre>
61     $cgivar{'name'} = 'Martin Schulze';
62     $cgivar{'email'} = 'joey@linux.de';
63 </pre>
64
65   Then let the library display the file by issuing the following
66   command: <p>
67
68 <pre>
69     print &cgivar_eval_head ($template,\%cgivar);
70 </pre>
71
72   As you can imagine the file is divided in more than just one part.
73   Indeed currently four parts are supported: <p>
74
75 <dl>
76 <dt> HEAD
77 <dd> Head of a template.
78
79 <dt> FOOT
80 <dd> Foot of a template.
81
82 <dt> ENTRY
83 <dd> Middle part of a template, may be repeated.
84
85 <dt> ALTERNATE
86 <dd> Alternate middle part, e.g. if no entries were found.
87 </dl>
88
89   Dividing up a template gives you a chance to provide variable HTML
90   code if this is required, e.g. when browsing through entries of a
91   database.  In that case, you will call cgivar_eval_entry() as often
92   as you need. <p>
93
94 <h3>The template</h3>
95
96   The template is - you guessed it - HTML code basically.  However,
97   some variables need to be present to be replaced by their actual
98   values.  These are denoted by &lt;cgivar name&gt;. <p>
99
100   A simple example would be: <p>
101
102 <pre>
103     &lt;html&gt;
104     &lt;head&gt;&lt;title&gt;&lt;cgivar title&gt;&lt;/title&gt;&lt;/head&gt;
105     &lt;body&gt;
106     &lt;h1&gt;&lt;cgivar title&gt;&lt;/h1&gt;
107     &lt;/body&gt;
108     &lt;/html&gt;
109 </pre>
110
111   When using different parts of a template you'll divide it up as
112   follows: <p>
113
114 <pre>
115     [head]
116     &lt;!-- Begin Entry --&gt;
117     [entry]
118     &lt;!-- Alternate Entry --&gt;
119     [alternate]
120     &lt;!-- End Entry --&gt;
121     [foot]
122 </pre>
123
124 <h3>Download</h3>
125
126 <a href="download/cgivar.pl">here</a> <p>
127
128 </projectpg>
129
130 # Local variables:
131 # mode: html
132 # mode: auto-fill
133 # end: