<?xml version="1.0" encoding="UTF-8" ?>
<rdf:RDF xmlns="http://usefulinc.com/ns/doap#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><Project><name>iw.recipe.template</name>
<shortdesc>ZC buildout recipe to build template based file</shortdesc>
<description>==========================
iw.recipe.template package
==========================

.. contents::

What is iw.recipe.template ?
============================

iw.recipe.template is a zc.buildout recipe to build template based
file/scripts

It also provide some recipe to build Zope2, Zope3 and Squid vhosts config
file for apache.

How to use iw.recipe.template ?
===============================

We need a buildout config file::

  &gt;&gt;&gt; server = start_server(test_dir)

  &gt;&gt;&gt; write(sample_buildout, 'buildout.cfg',
  ... """
  ... [buildout]
  ... parts = template.txt
  ...
  ... [template.txt]
  ... recipe = iw.recipe.template
  ... source = %s/template.txt_impl
  ... destination = %s/
  ... """ % (sample_buildout, sample_buildout))

And a template::

  &gt;&gt;&gt; template = join(sample_buildout, 'template.txt_impl')
  &gt;&gt;&gt; open(template, 'w').write('''My template is named "$name"''')


Then, the recipe should work::

  &gt;&gt;&gt; print system(buildout)
  Installing template.txt.
  template.txt: Generated file 'template.txt'.

Here is the result::

  &gt;&gt;&gt; print open(join(sample_buildout, 'template.txt')).read()
  My template is named "template.txt"


Now we can generate an executable::  

  &gt;&gt;&gt; write(sample_buildout, 'buildout.cfg',
  ... """
  ... [buildout]
  ... parts = script
  ...
  ... [script]
  ... recipe = iw.recipe.template:script
  ... source = %s/template.py_impl
  ... destination = %s/
  ... """ % (sample_buildout, sample_buildout))


We need a small template with a python script::

  &gt;&gt;&gt; template = join(sample_buildout, 'template.py_impl')
  &gt;&gt;&gt; open(template, 'w').write('''
  ... import sys
  ... print 'this is the script named "$name"'
  ... ''')

Run buildout again::

  &gt;&gt;&gt; print system(buildout)
  Uninstalling template.txt.
  Installing script.
  script: Generated script 'script'.

Here is the result::

  &gt;&gt;&gt; print open(join(sample_buildout, 'script')).read()
  #!/.../bin/python
  &lt;BLANKLINE&gt;
  import sys
  print 'this is the script named "script"'
  &lt;BLANKLINE&gt;

  &gt;&gt;&gt; print system(join(sample_buildout, 'script'))
  this is the script named "script"</description>
<maintainer><foaf:Person><foaf:name>Ingeniweb</foaf:name>
<foaf:mbox_sha1sum>ce647768fc2915c7851be5591bf96a90966761ef</foaf:mbox_sha1sum></foaf:Person></maintainer>
<release><Version><revision>0.2</revision></Version></release>
</Project></rdf:RDF>