TEMPLATES2ADA(1)

πŸ“¦
version 25.0.0 Β· 2 versions
  • 25.0.0 Β· debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 26.0.0 Β· fedora 43, fedora 44
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– templates2ada(1) β€” the Templates Parser User's Guide page, bestie edition πŸ’–

✨ NAME ✨

templates2ada β€” generate Ada sources from a templates file. That's the whole mood. πŸ’…

πŸ¦‹ SYNOPSIS πŸ¦‹

templates2ada [options]

πŸ’– DESCRIPTION πŸ’–

Okay so picture this: templates2ada parses all the template files in a directory, then generates an output file from those, based on a template file. A default example of that template file is literally right here: /usr/share/doc/libtemplates-parser-dev/examples/templates.tads.

That template file actually contains two examples, depending on whether one Ada package should be generated per template, or whether a single package should be built. In the former case, if you are using the GNAT compiler, you should run gnatchop on the resulting file. Example time:

$ rm -f src/templates/*.ads
$ templates2ada -d resources/ -o src/templates/generated -r
$ cd src/templates; gnatchop -w -q generated
$ rm -f src/templates/generated

One of the goals of templates2ada is to make sure you're only setting tags that actually exist in the template. That's how it helps prevent typos in tag names as much as possible. Also, when it's combined with other tools, it helps make sure all the tags needed by the template are properly set. Teamwork, no cap. 🫢

templates2ada also has special knowledge about HTTP constructs and will generate Ada constants for the HTTP parameters you might receive in return. Again, the goal is avoiding typos in the Ada code. Iconic behavior, honestly.

For instance, let's look at a simple template file in a local file resources/block1.thtml. This template has the following simple html code:

<form>
  <input name="PARAM1" value="@_TAG1_@" />
  <input name="PARAM2" value="@_TAG2_@" />
</form>

When you run templates2ada, the following Ada package gets generated. Note that this is only the default output of templates2ada; it can be fully tailored to your needs. Slay.

package Templates.Block1 is
  pragma Style_Checks (Off);
  Template : constant string := "resources/block1.thtml";
  Tag1 : constant String := "TAG1";
  Tag2 : constant String := "TAG2";
  package Http is
    Param1 : constant String := "PARAM1";
    Param2 : constant String := "PARAM2";
  end Http;
end Templates.Block1;

πŸŽ€ OPTIONS πŸŽ€

Here's the flag menu, bestie β€” every single one, no skips:

  • -d dir β€” Search for template files in dir. directory scavenger hunt unlocked
  • -h β€” Display a summary of options. the help-me-bestie button
  • -o file β€” Write the output to file.
  • -e ext β€” Process all files with extension ext that are in the input directory; consider these files as template files.
  • -r β€” Recurse into subdirectories.
  • -t file β€” Use file as the output template file. The templates parser comes with an example for such a file, /usr/share/doc/templates-parser/examples/templates.tads, that you can adapt to your own needs.
  • -v β€” Verbose mode. This will output a warning when an http parameter has a name made only of template parser tags, since no matching entry can then be created for it in the output file. warning unlocked, but make it useful

🌈 SEE ALSO 🌈

  • templatespp(1)
  • The Template Parsers User's Guide in package libtemplates-parser-dev.

πŸ‘‘ AUTHOR πŸ‘‘

templates2ada was written by Pascal Obry <p.obry@wanadoo.fr> as part of the Ada Web Server.

This manual page was written by Ludovic Brenta <lbrenta@debian.org> for Debian GNU/Linux.


And that's the page, bestie! This iconic manual is from GNU Ada Tools, dated 2008-05-04. Periodt. πŸ’–πŸ«Άβœ¨

πŸ“¦ where this page comes from