The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

tmpl_test.pl - test parse the templates used in a HTML::Template invocation.

SYNOPSIS

This script will test the validity of a template that is going to be used by an invocation of HTML::Template. Example:

  tmpl_test.pl somefile.tmpl

or:

  tmpl_test.pl -r

Recursively finds templates, searching from the current directory, then test-parsing each template file validating the syntax.

DESCRIPTION

While developing templates for use in your application, you may find that you end up using a development model where you spend a lot of time making changes to templates, then trying to generate output with them, just to find out that you made an error in one (or more) of the templates that you were just working on. This often results in lots of small time wastages since your development environment may be setup to test your end-to-end framework, rather than individual changes.

Also, if your are modifying a number of templates in one sitting, often you will make a mistake, which is hard to detect and analyse, using a normal HTML::Template invocation.

The aim of this script is simply to test-parse template files, so as to catch common TMPL-type syntax errors. This test-parse will find most errors in each template file, thus it allows you to test-parse included files, individually, rather than simply invoking HTML::Template on the top-level template.

USAGE

tmpl_test.pl takes the following arguments (using defaults if not specified):

 -r   Recursively search for templates from current directory.

 -t   Specify a file specification for recursive searches,
      defaults to: *.tmpl

 -s   Specify a directory to be added to H::T's search path,
      defaults to including the current directory.

 -f   Specify the name of a template file to test.  You can
      specify multiple '-f's on the command line; each
      template will be tested in order of specification.

 -o   Show outout of template parse (this is probably only
      useful when testing a single template.

 -p   Sets params so that they can be used within template
      tests.  Use multiple -p's to add more params.
      Syntax: -p "key" "value"

Any argument that doesn't begin with a '-', is assumed to be a filename, so that you can do something like:

  tmpl_test.pl include/template1.tmpl template2.tmpl

Note that '-r' overrides any files specified on the command line.

CAVEATS

This module uses HTML::Template::Expr to do the actual test. If H::T or H::T::E themselves cannot detect an error within a template, then neither can this script.

AUTHORS

Mathew Robertson <mathew@users.sf.net>

LICENCE

Copyright (C) 2004 Mathew Robertson

This module is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 (or any later version) as published by the Free Software Foundation.