[%#
# IMPORTANT NOTE
# This documentation is generated automatically from source
# templates. Any changes you make here may be lost.
#
# The 'docsrc' documentation source bundle is available for download
# from http://www.template-toolkit.org/docs.html and contains all
# the source templates, XML files, scripts, etc., from which the
# documentation for the Template Toolkit is built.
-%]
[% META book = 'Tools'
page = 'ttree'
%]
[% WRAPPER toc;
PROCESS tocitem
title ="SYNOPSIS"
subs = [];
PROCESS tocitem
title ="DESCRIPTION"
subs = [
"The
ttree [options] [files][%- END %] [% WRAPPER section title="DESCRIPTION" -%]
The
It supports a number of options which can be used to configure
behaviour, define locations and set Template Toolkit options. The
script first reads the '-f'
(file)
option.
When you run
$ ttree Do you want me to create a sample '.ttreerc' file for you? (file: /home/abw/.ttreerc) [y/n]: y /home/abw/.ttreerc created. Please edit accordingly and re-run ttree
The purpose of this file is to set any global configuration options
that you want applied every time 'ignore'
and 'copy'
option to provide regular expressions
that specify which files should be ignored and which should be copied
rather than being processed as templates. You may also want to set
flags like 'verbose'
and 'recurse'
according to your preference.
A minimal
# ignore these files ignore = \b(CVS|RCS)\b ignore = ^# ignore = ~$
# copy these files copy = \.(gif|png|jpg|pdf)$
# recurse into directories recurse
# provide info about what's going on verbose
In most cases, you'll want to create a different 'cfg'
option allows you
to specify a directory where
cfg = /home/abw/.ttree
The '-f'
command line option can be used to specify which configuration
file should be used. You can specify a filename using an absolute or
relative path:
$ ttree -f /home/abw/web/example/etc/ttree.cfg $ ttree -f ./etc/ttree.cfg $ ttree -f ../etc/ttree.cfg
If the configuration file does not begin with '/'
or '.'
or something
that looks like a MS-DOS absolute path (e.g. 'C:\\etc\\ttree.cfg'
) then
'cfg'
option.
$ ttree -f test1 # /home/abw/.ttree/test1
The 'cfg'
option can only be used in the
Remember that '-f'
option. Certain options
like 'lib'
can be used any number of times and accumulate their values.
For example, consider the following configuration files:
cfg = /home/abw/.ttree lib = /usr/local/tt2/templates
lib = /home/abw/web/example/templates/lib
When
$ ttree -f myconfig
the 'lib'
option will be set to the following directories:
/usr/local/tt2/templates /home/abw/web/example/templates/lib
Any templates located under
The 'src'
option is used to define the directory containing the
source templates to be processed. It can be provided as a command
line option or in a configuration file as shown here:
src = /home/abw/web/example/templates/src
Each template in this directory typically corresponds to a single web page or other document.
The 'dest'
option is used to specify the destination directory for the
generated output.
dest = /home/abw/web/example/html
The 'lib'
option is used to define one or more directories containing
additional library templates. These templates are not documents in
their own right and typically comprise of smaller, modular components
like headers, footers and menus that are incorporated into pages templates.
lib = /home/abw/web/example/templates/lib lib = /usr/local/tt2/templates
The 'lib'
option can be used repeatedly to add further directories to
the search path.
A list of templates can be passed to
$ ttree foo.html bar.html
It looks for these templates in the 'src'
directory and processes them
through the Template Toolkit, using any additional template components
from the 'lib'
directories. The generated output is then written to
the corresponding file in the 'dest'
directory.
If 'src'
directory.
If the '-r'
(recurse) option is set then it will additionally iterate
down through sub-directories and process and other template files it finds
therein.
$ ttree -r
If a template has been processed previously,
$ tree -a
Any templates explicitly named as command line argument are always processed and the modification time checking is bypassed.
[%- END %] [% WRAPPER subsection title = "File Options" -%]
The 'ignore'
, 'copy'
and 'accept'
options are used to specify Perl
regexen to filter file names. Files that match any of the 'ignore'
options will not be processed. Remaining files that match any of the
'copy'
regexen will be copied to the destination directory. Remaining
files that then match any of the 'accept'
criteria are then processed
via the Template Toolkit. If no 'accept'
parameter is specified then
all files will be accepted for processing if not already copied or
ignored.
# ignore these files ignore = \b(CVS|RCS)\b ignore = ^# ignore = ~$
# copy these files copy = \.(gif|png|jpg|pdf)$
# accept only .tt2 templates accept = \.tt2$
The 'suffix'
option is used to define mappings between the file
extensions for source templates and the generated output files. The
following example specifies that source templates with a '.tt2'
suffix should be output as '.html'
files:
suffix tt2=html
Or on the command line,
--suffix tt2=html
You can provide any number of different suffix mappings by repeating this option.
[%- END %] [% WRAPPER subsection title = "Template Dependencies" -%]
The 'depend'
and 'depend_file'
options allow you to specify
how any given template file depends on another file or group of files.
The 'depend'
option is used to express a single dependency.
$ ttree --depend foo=bar,baz
This command line example shows the '--depend'
option being used to
specify that the
$ ttree --depend foo=bar,baz --depend crash=bang,wallop
or in a configuration file:
depend foo=bar,baz depend crash=bang,wallop
The file appearing on the left of the '='
is specified relative to
the 'src'
or 'lib'
directories. The file(s) appearing on the right
can be specified relative to any of these directories or as absolute
file paths.
For example:
$ ttree --depend foo=bar,/tmp/baz
To define a dependency that applies to all files, use '*'
on the
left of the '='
.
$ ttree --depend *=header,footer
or in a configuration file:
depend *=header,footer
Any templates that are defined in the 'pre_process'
, 'post_process'
,
'process'
or 'wrapper'
options will automatically be added to the
list of global dependencies that apply to all templates.
The 'depend_file'
option can be used to specify a file that contains
dependency information.
$ ttree --depend_file=/home/abw/web/example/etc/ttree.dep
Here is an example of a dependency file:
# This is a comment. It is ignored. index.html: header footer menubar header: titlebar hotlinks menubar: menuitem # spanning multiple lines with the backslash another.html: header footer menubar \ sidebar searchform
Lines beginning with the '#'
character are comments and are ignored.
Blank lines are also ignored. All other lines should provide a
filename followed by a colon and then a list of dependant files
separated by whitespace, commas or both. Whitespace around the colon
is also optional. Lines ending in the '\'
character are continued
onto the following line.
Files that contain spaces can be quoted. That is only necessary for files after the colon (':'). The file before the colon may be quoted if it contains a colon.
As with the command line options, the '*'
character can be used
as a wildcard to specify a dependency for all templates.
* : config,header[%- END %] [% WRAPPER subsection title = "Template Toolkit Options" -%]
'--pre_chomp'
and '--post_chomp'
'PRE_CHOMP'
and 'POST_CHOMP'
options.
Run 'ttree -h'
for a summary of the options available.
Andy Wardley <abw@andywardley.com>
[% ttlink('http://www.andywardley.com/', 'http://www.andywardley.com/') -%]
With contributions from Dylan William Hardison (support for
dependencies), Bryce Harrington ('absolute'
and 'relative'
options),
Mark Anderson ('suffix'
and 'debug'
options), Harald Joerg and Leon
Brocard who gets everywhere, it seems.
2.70, distributed as part of the Template Toolkit version 2.14, released on 04 October 2004.
[%- END %] [% WRAPPER section title="COPYRIGHT" -%]Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved. Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
[%- END %] [% WRAPPER section title="SEE ALSO" -%][% ttlink('Template::Tools::tpage', 'tpage') -%]
[%- END %]