Total Pageviews

Monday 16 June 2014

templatifier

The idea of this project is to use standard HTML as templates to generate static sites dynamically. This is useful for distributing sites on a CD or to be able to use a cheaper hosting package and still have some of the functionality of a content managed system.

Introduction

The templater.py script replaces blocks of text in a standard html file. The blocks to be replaced inside the template are marked simply by the id of the tag. Take for example the following html (we'll call it template.html):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>This title should get replaced</title>
  <head>
  <body>
    <h1 id="title">Title</h1>
    <div id="content">
      Filler filler blah blah
      Filler filler bla
    </div>
  </body>
</html>
To use this html as a template, execute the following command:
  python templater.py -t "New Title" -v title="Header Title" -v content="Now this is content" template.html outfile.html
This will create an output file with the specified blocks replaced.
For more details, see UsingTemplater

from https://code.google.com/p/templatifier/
https://templatifier.googlecode.com/files/templater-0.01.py