NAME

telf - Process templates using YAML input

SYNOPSIS

telf --recurse [options] template|directory... directory

telf --iterate [options] template

telf [options] template

DESCRIPTION

telf is a general-purpose template-processing program that makes it possible to define template variables and configuration settings using YAML files. It processes templates written in Template Toolkit (version 2) syntax and is meant as a more powerful alternative to both tpage(1) and ttree(1).

telf may be invoked in different ways (the so-called run modes) to accomplish three different tasks:

Recursive processing

This processes a file tree containing multiple templates, putting the output of each file into the corresponding file in a separate file tree, and is similar to the use of ttree(1).

Patterns may be used to limit the files to process as templates, to specify files that should be copied rather than being processed as templates, and to filter out files that should be skipped altogether.

Recursive processing is indicated by use of the -r (or --recurse) option.

Iterative processing

In iterative processing, a single template is processed multiple times, once for each value found in a YAML data file.

For example, take the following simple template:

    # Template `person.tt2':
    [% person.name %] is [% person.age %] years old.

Assume the following data file, which contains two values in YAML format:

    # Data file `people.yaml':
    --- #YAML:1.0
    name: Ulysses K. Fishwick
    age: 93
    --- #YAML:1.0
    name: Yolanda P. Ipswich
    age: 2

To process a template iteratively, use the -e or --iterate option to specify the YAML data file and the name of the variable which will hold each value in turn, like this:

telf --iterate variable=datafile template

In the case of this example, the command would be as follows:

    telf --iterate person=people.yaml person.tt2

The output will be as follows:

    Ulysses K. Fishwick is 93 years old.
    Yolanda P. Ipswich is 2 years old.

(Other options may be specified as well, in any order.)

Processing a single template

This corresponds to the use of tpage(1) to process a single template, except that the resulting output is always simply written to standard output.

Single-template processing is indicated by the absence of -r, --recurse, -e, and --iterate options.

OPTIONS

Command-line options fall mostly into three categories: template configuration (specifying Template Toolkit configuration settings), template variables (data used by the template itself to generate the desired output), and template selection (specifying which template(s) to apply).

Most options have a long form (e.g., --recurse) as well as a short form (e.g., -r).

Special options

The following options have special meaning:

Defining configuration parameters

The following options are used to define Template Toolkit configuration parameters, and are valid in any run mode.

Defining template variables

The following options are used to define variables whose values may be used in processing templates; these options are valid in any run mode.

Run modes

File actions

The next two options may be used in any run mode to specify templates for pre- or post-processing. Their significance varies slightly depending on the run mode.

The following options are valid only in recursive processing; they delimit which files are to be processed as templates, which files are to be copied, and which files are to be skipped altogether.

These next options are valid only in iterative processing.

DIAGNOSTICS

In recursive mode, and if you've specified verbose mode (-v or --verbose), each source file will be reported along with a code indicating whether the file was processed as a template, copied, skipped, and so on.

If a file in the destination tree was deleted (because the corresponding file in the source tree was skipped and the -Z or --delete-skipped-files option was specified), then the deleted file is reported, not the source file corresponding to it. Otherwise, it's the source file that's reported.

The following symbols are used:

TO DO

Enable the use of dotted-path notation to set variables. For example:

    telf -D variables.yaml -d people.3.name=Fishwick

Extract core functionality into a Perl module and leave hooks for data formats other than YAML?

AUTHOR

Paul Hoffman (nkuitse AT nkuitse DOT com)

COPYRIGHT

Copyright 2004-2006 Paul M. Hoffman.

This is free software, distributed under the same terms as Perl itself.

BUGS

No known bugs.

SEE ALSO

Template, YAML, IO::YAML.