/usr/share/doc/libtemplates-parser-doc/examples/templates.tads is in libtemplates-parser-doc 17.2-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | @@-- This template is intended as a model of how to generate an Ada package
@@-- describing all the variables used in a set of AWS templates.
@@-- These Ada packages can then be used in your application to avoid
@@-- hard-coded strings, and help maintain the templates and the code to
@@-- parse them in sync.
@@--
@@-- This template contains two possible behaviors, chosen through the
@@-- following variable:
@@SET@@ SINGLE_FILE = False
@@-- If you set it to True, then a single Ada package with its nested
@@-- packages is generated. If you set it to False, then the file generated
@@-- should be further processed through gnatchop, to generate several
@@-- Ada files organized into several files. This latter organization
@@-- avoids recompiling all your source files every time at least one
@@-- template changes.
@@--
@@-- The following variable should be changed to set the name of the
@@-- generated packages.
@@SET@@ PACKAGE = Templates
@@--
@@--
@@-- When designing your own template for Ada packages, you should take
@@-- into account that the variables in your templates might not necessarily
@@-- be valid Ada identifier names, and you should therefore update the calls
@@-- to @_REPLACE:..._@ below.
@@--
@@-- This template example also assumes a convention for Lazy_Tags. If you
@@-- are using such types, they are generally shared among templates, and
@@-- the Ada package should reflect that fact. Assuming all such tags start
@@-- with the prefix LAZY_, we generate one special package for them, and
@@-- omit them in all the other packages.
@@--
@@-- Likewise, the templates2ada tool will not generate tag entries for tags
@@-- that are set through a @@SET@@ statement, since these are purely internal
@@-- to your template file and have no impact on your source code.
@@--
@@-- For the best use of this tool, it is recommended that your template not
@@-- use @@INCLUDE@@ statements, but instead use a tag, set in the Ada code
@@-- to the preprocessed result of the same template file. This allows you to
@@-- better control unset tags. For instance, instead of using:
@@-- @@INCLUDE@@ foo.thtml
@@-- use something like:
@@-- @_BLOCK_FOO_@
@@-- and in your Ada code set BLOCK_FOO to the result of Parse ("foo.thtml").
@@--
@@-- The templates2ada tool is able to generate constants for the HTTP
@@-- parameters set in your page, so that you can process them in your Ada
@@-- code. A few conventions must be followed, however:
@@-- - The name should be on a single line, preceded by "name=", as in
@@-- name="FOO"
@@-- - The name should use only letters, underscores and digits, unless you
@@-- enhance the regular expressions below to also remove other special
@@-- characters.
@@-- - In some cases, you must use a AWS tag in the name of an HTTP param,
@@-- for instance for checkboxes for which names should be unique (or you
@@-- won't know when the parameter is set to false). In this case, the
@@-- tag must be at the beginning or end of the name, not in the middle.
@@-- If there are multiple tags, they should be separated by non-letters,
@@-- as in:
@@-- name="PN_@_TAG1_@:@_TAG2_"
@@-- In this case, the following constant is generated:
@@-- PN_Prefix : constant String := "PN";
@@-- - The name mustn't be only an AWS tag. The following is invalid:
@@-- name="@_TAG_@"
@@-- To avoid generating constants for <a name=..>, you must put the name
@@-- attribute right after the "<a". templates2ada doesn't try to parse the
@@-- HTML file, and doesn't know anything about HTML structure.
@@--
@@-- Some HTTP parameters can be specified as GET parameters. These can be
@@-- documented directly in the templates with the following format:
@@-- @@-- HTTP_GET(name): documentation
@@-- and an entry will be generated for it.
@@-- One additional special kind of comment that is recognized by this tool is
@@-- @@-- HTTP_URL(url): documentation
@@-- This indicates the typical URL(s) associated with that template, and will
@@-- result in an additional string constant in the generated package, which
@@-- can for instance be used when registering the URLs, or when redirecting
@@-- the user to another URL.
@@--
@@-- If you combine the use of HTTP_GET and HTTP_URL, this can help ensure
@@-- that any URL redirection you do through AWS.Response.URL is valid, if you
@@-- use the generated constants. In addition, you could generate a
@@-- template file (for instance using all_urls.thtml in this distribution)
@@-- that can be included in other templates.
@@--
@@-- When a variable is removed from a template, your source code will no
@@-- longer compile. When a variable is added, you get no compilation error.
@@-- However, running "gnat xref -u" on your application will help detect
@@-- unreferenced variables, and thus tags that are used in templates but
@@-- never set in the code. For instance:
@@-- gnat xref -Pproject -u main.adb | grep templates
@@-- will list all unused template variables from the template packages that
@@-- are currently in use by your application. Template packages that are not
@@-- even withed will not appear in this listing, but can generally be found
@@-- through appropriate grep commands.
@@--
@@-- The following tags are available in this template:
@@-- @_VARIABLE_@: Matrix of variable names for the current template,
@@-- sorted alphabetically
@@-- @_FILENAME_@: Vector of template file names. The name contains
@@-- directories relative to the directory given to
@@-- templates2ada
@@-- @_BASENAME_@: Same as @_FILENAME_@, but contains only the base
@@-- names of files, with no extension.
@@-- @_VARIABLE_LIST_@: List of all variables defined in all templates,
@@-- sorted alphabetically
@@-- @_INCLUDE_@: List of templates included by the current template.
@@-- Names are the base name.
@@-- @_HTTP_@: List of http parameters that can be returned by the
@@-- current template, sorted alphabetically.
@@-- @_FROM_GET_@: For each of the HTTP parameters above, this boolean
@@-- indicates whether it was defined in a HTTP_GET
@@-- comment as explained above.
@@-- @_URL_@: List of urls that are associated with the current
@@-- template, sorted alphabetically.
@@-- @_AJAX_EVENT_@: Event name (onclick, onchange...), corresponding
@@-- action in AJAX_ACTION.
@@-- @_AJAX_ACTION_@ Action for the given AJAX_EVENT above.
@@-- @_AJAX_FILE_@ File in which the corresponding action has been
@@-- found.
@@-- @_SET_VAR_@ Name of SET constants in the template
@@-- Only variables with prefix SET_ are exported.
@@-- @_SET_VAL@ Values of the above constants.
@@--
@@-- This templates is processed through the tool templates2ada
@@--
@@-- Possible enhancements:
@@-- - Take into account @@IF@@ statements, and make sure that all
@@-- needed variable in each branch is properly set. Hard to do.
@@-- - Have a way to specify comments for the variable, probably as a
@@-- special comment in the template files themselves.
@@-- - Handling of @@INCLUDE@@: the tags defined in the included file
@@-- be also included in the generated package for the template, so
@@-- that we can detect missing definitions. However, this means that
@@-- such tags will be duplicated in several places... It is generally
@@-- simpler to avoid using @@INCLUDE@@ statements.
@@-- We could also use child packages to represent them
@@--
-- DO NOT EDIT, THIS FILE HAS BEEN GENERATED
package @_PACKAGE_@ is
pragma Style_Checks (Off);
package Lazy is
@@TABLE@@
@@IF@@ @_UPPER:SLICE(1..5):VARIABLE_LIST_@ = "LAZY_"
@_CAPITALIZE:REPLACE_ALL(__/_):VARIABLE_LIST_@ : constant String := "@_VARIABLE_LIST_@";
@@END_IF@@
@@END_TABLE@@
end Lazy;
@@IF@@ @_SINGLE_FILE_@ = True
@@TABLE@@
package @_CAPITALIZE:REPLACE_ALL(\./_):BASENAME_@ is
Template : constant String := "@_FILENAME_@";
@@TABLE@@@
@@IF@@ not @_IS_EMPTY:URL_@
@@IF@@ @_TABLE_LINE_@ = 1
URL : constant String := "@_URL_@";
@@ELSE@@
URL@_TABLE_LINE_@ : constant String := "@_URL_@";
@@END_IF@@
@@END_IF@@
@@END_TABLE@@
@@TABLE@@
@@IF@@ not @_IS_EMPTY:VARIABLE_@ and @_UPPER:SLICE(1..5):VARIABLE_@ /= "LAZY_"
@_CAPITALIZE:REPLACE_ALL(__/_):VARIABLE_@ : constant String := "@_VARIABLE_@";
@@END_IF@@
@@END_TABLE@@
@@IF@@ @_EXIST:HTTP_@
package HTTP is
@@TABLE@@
@@IF@@ not @_IS_EMPTY:HTTP_@
@_CAPITALIZE:REPLACE_ALL(__/_):HTTP_@ : constant String := "@_HTTP_@";
@@END_IF@@
@@END_TABLE@@
end HTTP;
@@END_IF@@
@@IF@@ @_EXIST:SET_VAR_@
package Set is
@@TABLE@@
@_CAPITALIZE:REPLACE_ALL(__/_):SET_VAR_@ : constant String := "@_SET_VAL_@";
@@END_TABLE@@
end Set;
@@END_IF@@
@@IF@@ @_EXIST:AJAX_EVENT_@
package Ajax is
@@TABLE@@
@@IF@@ not @_IS_EMPTY:AJAX_EVENT_@
@_CAPITALIZE:AJAX_EVENT_@_@_CAPITALIZE:AJAX_ACTION_@ : constant String := "/@_AJAX_EVENT_@$@_AJAX_ACTION_@";
@@END_IF@@
@@END_TABLE@@
end Ajax;
@@END_IF@@
end @_CAPITALIZE:REPLACE_ALL(\./_):BASENAME_@;
@@END_TABLE@@
@@END_IF@@
end @_PACKAGE_@;
@@IF@@ @_SINGLE_FILE_@ /= True
@@TABLE@@
@@-- @@TABLE@@
@@-- @@IF@@ @_EXIST:INCLUDE_@
@@-- with @_PACKAGE_@.@_CAPITALIZE:REPLACE_ALL(\./_):INCLUDE_@;
@@-- @@END_IF@@
@@-- @@END_TABLE@@
-- DO NOT EDIT, THIS FILE HAS BEEN GENERATED
package @_PACKAGE_@.@_CAPITALIZE:REPLACE_ALL(\./_):BASENAME_@ is
pragma Style_Checks (Off);
Template : constant String := "@_FILENAME_@";
@@TABLE@@@
@@IF@@ not @_IS_EMPTY:URL_@
@@IF@@ @_TABLE_LINE_@ = 1
URL : constant String := "@_URL_@";
@@ELSE@@
URL@_TABLE_LINE_@ : constant String := "@_URL_@";
@@END_IF@@
@@END_IF@@
@@END_TABLE@@
@@TABLE@@
@@IF@@ not @_IS_EMPTY:VARIABLE_@ and @_UPPER:SLICE(1..5):VARIABLE_@ /= "LAZY_"
@_CAPITALIZE:REPLACE_ALL(__/_):VARIABLE_@ : constant String := "@_VARIABLE_@";
@@END_IF@@
@@END_TABLE@@
@@IF@@ @_EXIST:HTTP_@
package HTTP is
@@TABLE@@
@@IF@@ not @_IS_EMPTY:HTTP_@
@_CAPITALIZE:REPLACE_ALL(__/_):HTTP_@ : constant String := "@_HTTP_@";
@@END_IF@@
@@END_TABLE@@
end HTTP;
@@END_IF@@
@@IF@@ @_EXIST:SET_VAR_@
package Set is
@@TABLE@@
@_CAPITALIZE:REPLACE_ALL(__/_):SET_VAR_@ : constant String := "@_SET_VAL_@";
@@END_TABLE@@
end Set;
@@END_IF@@
@@IF@@ @_EXIST:AJAX_EVENT_@
package Ajax is
@@TABLE@@
@@IF@@ not @_IS_EMPTY:AJAX_EVENT_@
@_CAPITALIZE:AJAX_EVENT_@_@_CAPITALIZE:AJAX_ACTION_@ : constant String := "/@_AJAX_EVENT_@$@_AJAX_ACTION_@";
@@END_IF@@
@@END_TABLE@@
end Ajax;
@@END_IF@@
end @_PACKAGE_@.@_CAPITALIZE:REPLACE_ALL(\./_):BASENAME_@;
@@END_TABLE@@
@@END_IF@@
|