|Do you know where your variables are?|
Re: Can you include templates in Template Toolkit without specifying the file extension?by shadowsong (Pilgrim)
|on May 16, 2017 at 21:23 UTC||Need Help??|
Here are a couple of things that might help – there are two ways to “attempt to use it” both of which ought to be installed as part of Template::Toolkit.
You need to specify the extension of the include files (and location of said include files if they're not in the current working directory). So your example.tt file will look like this:
…and the command to generate your output could look something like:tpage --relative --include_path='relative path/to/header.tt and footer.tt' example.tt
This requires a bit more setup and can be fiddly at first but is worth it…
Let's assume you're working on a site called trixietang.co.uk and Template::Toolkit has already been installed.
Step 1 - generate base .ttreerc default filettree
This will prompt you to create a sample .ttreerc file - optional but useful step to help you understand what the various directives are in Step 3 below.
Step 2 - create site directory structure
Step 3 - edit ttree config files
.ttreerc – tweak entries in ~/.ttreerc (or $HOME\.ttreerc if you're on Win32)
trixietang.co.uk.conf – create a new file: ~/templates/cfg/trixietang.co.uk.conf and add the following contents:
Step 4 - put include files in ~/templates/trixietang.co.uk/lib
Step 5 - create source template files in ~/templates/trixietang.co.uk/src
Step 6 - run ttree command from ~/templates/cfg
If all goes well; you should then see your output files generated under ~/dist/trixietang.co.uk stripped of their tt suffix…
Feel free to play around with your ttree config files from Step 3 – altering depends and dest as required.