Bill Moseley wrote:
> Issue 2: Making the site build with ttree at different locations
> 
> What do people do to override configuration setting.  Again, I use ttree to
> generate the site, and ttree does a pre_process = config.  I want "config"
> to contain the settings where the real live site is, but I want an easy way
> to override these when developing on a different machine.

Hi Bill,

Here's an (untested) example hacked from one of our projects.  Create a
file 'config' with a bunch of config hashes:

[% foo = {
           a => 'foo',
         }
%]
[% bar = {
           a => 'bar',
         }
%]
[% default = {
              a => 'quux',
              b => 'quux'
             }
%]
[%# set defaults %]
[% FOREACH key = default.keys %]
  [% IF ! $conf.$key.defined %]
    [% $conf.$key = default.$key %]
  [% END %]
[% END %]
[%# assign config %]
[% conf = $conf %]

Create '.ttreerc.conf' which whatever config you want and end it with
the line

  pre_process = config

Refer to your config variables in you templates like this

  [% conf.a %]

To configure for 'foo' run ttree like this

  ttree -a -f .ttreerc.conf --define conf=foo
 

Cheers,

paul

-- 
Paul Sharpe                   Tel: +44 (20) 7407 5557
Miraclefish Ltd.              Fax: +44 (20) 7378 8711
Studio 12                     mailto:[EMAIL PROTECTED]
37 Tanner Street              http://www.miraclefish.com/
London SE1 3LF
UNITED KINGDOM


Reply via email to