1Template::Tools::ttree(U3s)er Contributed Perl DocumentatTieomnplate::Tools::ttree(3)
2
3
4

NAME

6       Template::Tools::ttree - Process entire directory trees of templates
7

SYNOPSIS

9           ttree [options] [files]
10

DESCRIPTION

12       The ttree script is used to process entire directory trees containing
13       template files.  The resulting output from processing each file is then
14       written to a corresponding file in a destination directory.  The script
15       compares the modification times of source and destination files (where
16       they already exist) and processes only those files that have been
17       modified.  In other words, it is the equivalent of 'make' for the
18       Template Toolkit.
19
20       It supports a number of options which can be used to configure
21       behaviour, define locations and set Template Toolkit options.  The
22       script first reads the .ttreerc configuration file in the HOME
23       directory, or an alternative file specified in the TTREERC environment
24       variable.  Then, it processes any command line arguments, including any
25       additional configuration files specified via the "-f" (file) option.
26
27   The .ttreerc Configuration File
28       When you run ttree for the first time it will ask you if you want it to
29       create a .ttreerc file for you.  This will be created in your home
30       directory.
31
32           $ ttree
33           Do you want me to create a sample '.ttreerc' file for you?
34           (file: /home/abw/.ttreerc)   [y/n]: y
35           /home/abw/.ttreerc created.  Please edit accordingly and re-run ttree
36
37       The purpose of this file is to set any global configuration options
38       that you want applied every time ttree is run.  For example, you can
39       use the "ignore" and "copy" option to provide regular expressions that
40       specify which files should be ignored and which should be copied rather
41       than being processed as templates.  You may also want to set flags like
42       "verbose" and "recurse" according to your preference.
43
44       A minimal .ttreerc:
45
46           # ignore these files
47           ignore = \b(CVS|RCS)\b
48           ignore = ^#
49           ignore = ~$
50
51           # copy these files
52           copy   = \.(gif|png|jpg|pdf)$
53
54           # recurse into directories
55           recurse
56
57           # provide info about what's going on
58           verbose
59
60       In most cases, you'll want to create a different ttree configuration
61       file for each project you're working on.  The "cfg" option allows you
62       to specify a directory where ttree can find further configuration
63       files.
64
65           cfg = /home/abw/.ttree
66
67       The "-f" command line option can be used to specify which configuration
68       file should be used.  You can specify a filename using an absolute or
69       relative path:
70
71           $ ttree -f /home/abw/web/example/etc/ttree.cfg
72           $ ttree -f ./etc/ttree.cfg
73           $ ttree -f ../etc/ttree.cfg
74
75       If the configuration file does not begin with "/" or "." or something
76       that looks like a MS-DOS absolute path (e.g. "C:\\etc\\ttree.cfg") then
77       ttree will look for it in the directory specified by the "cfg" option.
78
79           $ ttree -f test1          # /home/abw/.ttree/test1
80
81       The "cfg" option can only be used in the .ttreerc file.  All the other
82       options can be used in the .ttreerc or any other ttree configuration
83       file.  They can all also be specified as command line options.
84
85       Remember that .ttreerc is always processed before any configuration
86       file specified with the "-f" option.  Certain options like "lib" can be
87       used any number of times and accumulate their values.
88
89       For example, consider the following configuration files:
90
91       /home/abw/.ttreerc:
92
93           cfg = /home/abw/.ttree
94           lib = /usr/local/tt2/templates
95
96       /home/abw/.ttree/myconfig:
97
98           lib = /home/abw/web/example/templates/lib
99
100       When ttree is invoked as follows:
101
102           $ ttree -f myconfig
103
104       the "lib" option will be set to the following directories:
105
106           /usr/local/tt2/templates
107           /home/abw/web/example/templates/lib
108
109       Any templates located under /usr/local/tt2/templates will be used in
110       preference to those located under /home/abw/web/example/templates/lib.
111       This may be what you want, but then again, it might not.  For this
112       reason, it is good practice to keep the .ttreerc as simple as possible
113       and use different configuration files for each ttree project.
114
115   Directory Options
116       The "src" option is used to define the directory containing the source
117       templates to be processed.  It can be provided as a command line option
118       or in a configuration file as shown here:
119
120           src = /home/abw/web/example/templates/src
121
122       Each template in this directory typically corresponds to a single web
123       page or other document.
124
125       The "dest" option is used to specify the destination directory for the
126       generated output.
127
128           dest = /home/abw/web/example/html
129
130       The "lib" option is used to define one or more directories containing
131       additional library templates.  These templates are not documents in
132       their own right and typically comprise of smaller, modular components
133       like headers, footers and menus that are incorporated into pages
134       templates.
135
136           lib = /home/abw/web/example/templates/lib
137           lib = /usr/local/tt2/templates
138
139       The "lib" option can be used repeatedly to add further directories to
140       the search path.
141
142       A list of templates can be passed to ttree as command line arguments.
143
144           $ ttree foo.html bar.html
145
146       It looks for these templates in the "src" directory and processes them
147       through the Template Toolkit, using any additional template components
148       from the "lib" directories.  The generated output is then written to
149       the corresponding file in the "dest" directory.
150
151       If ttree is invoked without explicitly specifying any templates to be
152       processed then it will process every file in the "src" directory.  If
153       the "-r" (recurse) option is set then it will additionally iterate down
154       through sub-directories and process and other template files it finds
155       therein.
156
157           $ ttree -r
158
159       If a template has been processed previously, ttree will compare the
160       modification times of the source and destination files.  If the source
161       template (or one it is dependant on) has not been modified more
162       recently than the generated output file then ttree will not process it.
163       The -a (all) option can be used to force ttree to process all files
164       regardless of modification time.
165
166           $ tree -a
167
168       Any templates explicitly named as command line argument are always
169       processed and the modification time checking is bypassed.
170
171   File Options
172       The "ignore", "copy" and "accept" options are used to specify Perl
173       regexen to filter file names.  Files that match any of the "ignore"
174       options will not be processed.  Remaining files that match any of the
175       "copy" regexen will be copied to the destination directory.  Remaining
176       files that then match any of the "accept" criteria are then processed
177       via the Template Toolkit.  If no "accept" parameter is specified then
178       all files will be accepted for processing if not already copied or
179       ignored.
180
181           # ignore these files
182           ignore = \b(CVS|RCS)\b
183           ignore = ^#
184           ignore = ~$
185
186           # copy these files
187           copy   = \.(gif|png|jpg|pdf)$
188
189           # accept only .tt2 templates
190           accept = \.tt2$
191
192       The "suffix" option is used to define mappings between the file
193       extensions for source templates and the generated output files.  The
194       following example specifies that source templates with a ".tt2" suffix
195       should be output as ".html" files:
196
197           suffix tt2=html
198
199       Or on the command line,
200
201           --suffix tt2=html
202
203       You can provide any number of different suffix mappings by repeating
204       this option.
205
206   Template Dependencies
207       The "depend" and "depend_file" options allow you to specify how any
208       given template file depends on another file or group of files.  The
209       "depend" option is used to express a single dependency.
210
211         $ ttree --depend foo=bar,baz
212
213       This command line example shows the "--depend" option being used to
214       specify that the foo file is dependant on the bar and baz templates.
215       This option can be used many time on the command line:
216
217         $ ttree --depend foo=bar,baz --depend crash=bang,wallop
218
219       or in a configuration file:
220
221         depend foo=bar,baz
222         depend crash=bang,wallop
223
224       The file appearing on the left of the "=" is specified relative to the
225       "src" or "lib" directories.  The file(s) appearing on the right can be
226       specified relative to any of these directories or as absolute file
227       paths.
228
229       For example:
230
231         $ ttree --depend foo=bar,/tmp/baz
232
233       To define a dependency that applies to all files, use "*" on the left
234       of the "=".
235
236         $ ttree --depend *=header,footer
237
238       or in a configuration file:
239
240         depend *=header,footer
241
242       Any templates that are defined in the "pre_process", "post_process",
243       "process" or "wrapper" options will automatically be added to the list
244       of global dependencies that apply to all templates.
245
246       The "depend_file" option can be used to specify a file that contains
247       dependency information.
248
249           $ ttree --depend_file=/home/abw/web/example/etc/ttree.dep
250
251       Here is an example of a dependency file:
252
253          # This is a comment. It is ignored.
254
255          index.html: header footer menubar
256
257          header: titlebar hotlinks
258
259          menubar: menuitem
260
261          # spanning multiple lines with the backslash
262          another.html: header footer menubar \
263          sidebar searchform
264
265       Lines beginning with the "#" character are comments and are ignored.
266       Blank lines are also ignored.  All other lines should provide a
267       filename followed by a colon and then a list of dependant files
268       separated by whitespace, commas or both.  Whitespace around the colon
269       is also optional.  Lines ending in the "\" character are continued onto
270       the following line.
271
272       Files that contain spaces can be quoted. That is only necessary for
273       files after the colon (':'). The file before the colon may be quoted if
274       it contains a colon.
275
276       As with the command line options, the "*" character can be used as a
277       wildcard to specify a dependency for all templates.
278
279           * : config,header
280
281   Template Toolkit Options
282       ttree also provides access to the usual range of Template Toolkit
283       options.  For example, the "--pre_chomp" and "--post_chomp" ttree
284       options correspond to the "PRE_CHOMP" and "POST_CHOMP" options.
285
286       Run "ttree -h" for a summary of the options available.
287

AUTHORS

289       Andy Wardley <abw@wardley.org>
290
291       <http://www.wardley.org>
292
293       With contributions from Dylan William Hardison (support for
294       dependencies), Bryce Harrington ("absolute" and "relative" options),
295       Mark Anderson ("suffix" and "debug" options), Harald Joerg and Leon
296       Brocard who gets everywhere, it seems.
297
299       Copyright (C) 1996-2007 Andy Wardley.  All Rights Reserved.
300
301       This module is free software; you can redistribute it and/or modify it
302       under the same terms as Perl itself.
303

SEE ALSO

305       Template::Tools::tpage
306
307
308
309perl v5.16.3                      2011-12-20         Template::Tools::ttree(3)
Impressum