1TEMPLATES2ADA(1) Templates Parser User's Guide TEMPLATES2ADA(1)
2
3
4
6 templates2ada - generate Ada sources from a templates file
7
9 templates2ada [options]
10
12 templates2ada parses all the template files in a directory and then
13 generates an output file from these, based on a template file (a
14 default example of which is provided as /usr/share/doc/libtemplates-
15 parser-dev/examples/templates.tads). The latter contains in fact two
16 examples, depending on whether one Ada package should be generated per
17 template, or whether a single package should be built. In the former
18 case, if you are using the GNAT compiler, you should run `gnatchop' on
19 the resulting file. Here is an example:
20
21 $ rm -f src/templates/*.ads
22 $ templates2ada -d resources/ -o src/templates/generated -r
23 $ cd src/templates; gnatchop -w -q generated
24 $ rm -f src/templates/generated
25
26 One of the goals of templates2ada is to ensure that you are only set‐
27 ting tags that actually exist in the template (and thus prevent, as
28 much as possibly, typos in the name of tags); also, when combined with
29 other tools, to help ensure that all tags needed by the template are
30 properly set.
31
32 templates2ada also has special knowledge about HTTP constructs and will
33 generate Ada constants for the HTTP parameters you might receive in
34 return. Once more the goal is to help avoid typos in the Ada code.
35
36 For instance, we will consider a simple template file, found in a local
37 file `resources/block1.thtml'. This template contains the following
38 simple html code:
39
40 <form>
41 <input name="PARAM1" value="@_TAG1_@" />
42 <input name="PARAM2" value="@_TAG2_@" />
43 </form>
44
45 When you run templates2ada, the following Ada package will be gener‐
46 ated. Note that this is only the default output of templates2ada, which
47 can be fully tailored to your needs.
48
49 package Templates.Block1 is
50 pragma Style_Checks (Off);
51 Template : constant string := "resources/block1.thtml";
52 Tag1 : constant String := "TAG1";
53 Tag2 : constant String := "TAG2";
54 package Http is
55 Param1 : constant String := "PARAM1";
56 Param2 : constant String := "PARAM2";
57 end Http;
58 end Templates.Block1;
59
60
62 -d dir Search for template files in dir.
63
64
65 -h Display a summary of options.
66
67
68 -o file
69 Write the output to file.
70
71
72 -e ext Process all files with extension ext that are in the input
73 directory; consider these files as template files.
74
75
76 -r Recurse into subdirectories.
77
78
79 -t file
80 Use file as the output template file. The templates parser comes
81 with an example for such a file, /usr/share/doc/templates-
82 parser/examples/templates.tads, that you can adapt to your own
83 needs.
84
85
86 -v Verbose mode. This will output a warning when an http parameter
87 has a name made only of template parser tags, since no matching
88 entry can then be created for it in the output file.
89
90
92 templatespp(1)
93
94 The Template Parsers User's Guide in package libtemplates-parser-dev.
95
96
98 templates2ada was written by Pascal Obry <p.obry@wanadoo.fr> as part of
99 the Ada Web Server.
100
101 This manual page was written by Ludovic Brenta <lbrenta@debian.org> for
102 Debian GNU/Linux.
103
104
105
106GNU Ada Tools 2008-05-04 TEMPLATES2ADA(1)