Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I use <a href="http://search.cpan.org/dist/Template-Toolkit/" rel="nofollow noreferrer">Template Toolkit</a> (Perl) and have a simple script that generates static files from the templates. This is great for the situation you are in (common navigation etc etc).</p> <p>It comes with a <code>ttree</code> command that'll process a directory tree and put the results in another.</p> <p>Here's the tt.rc file I use:</p> <pre><code># ignore these files (regular expressions) ignore = \.svn ignore = ^# ignore = ~$ ignore = .DS_Store ignore = \.tt$ # if these template files change, reprocess everything depend *=tpl/wrapper,tpl/defaults,style/default.html # just copy these files, don't process as templates copy = \.(gif|png|pdf|jpg)$ # verbose output verbose # recurse into subdirectories recurse # setup some defaults from tpl/defaults pre_process = tpl/defaults # process this file instead of the real file (see below how this is used) process = tpl/wrapper # process files from src/, output to html/ # extra templates in lib/ (tpl/wrapper for example). src = src dest = html lib = lib </code></pre> <p>A couple of special files, <code>tpl/defaults</code> is</p> <pre><code>[%- page = { title = template.title, style = template.style or 'default.html' }; base = INCLUDE tpl/base_uri; # don't include any whitespace from here... RETURN; -%] </code></pre> <p>And <code>tpl/wrapper</code> is</p> <pre><code>[%- content = PROCESS $template; IF !template.name.search('.html') OR page.style == 'none'; content; ELSE; default_style_template = "style/" _ page.style; PROCESS $default_style_template; END; %] </code></pre> <p>This will process the real template; put the results in the <code>content</code> variable and then process the <code>style</code> template (set with <code>page.style</code> in <code>tpl/defaults</code>; defaults to <code>defaults.html</code>).</p> <p>the <code>lib/style/default.html</code> style file just needs to have </p> <pre><code>[% content %] </code></pre> <p>somewhere to include the real template; before and after that you can have the standard footer and headers.</p> <p>You can read more about Template Toolkit at <a href="http://tt2.org/" rel="nofollow noreferrer">tt2.org</a>.</p> <p>Another option would be to use <code>wget</code> (or similar) in recursive mode to "mirror" pages generated by PHP on the development server; but I wouldn't recommend that.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload