changeset 477:477fac8052e3 trunk

Update documentation to include the new #include directive in text templates.
author cmlenz
date Mon, 14 May 2007 20:27:26 +0000
parents 1bb01fce61ba
children 94191f4233f3
files doc/text-templates.txt
diffstat 1 files changed, 34 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/doc/text-templates.txt
+++ b/doc/text-templates.txt
@@ -184,6 +184,40 @@
     Hello, world!
 
 
+.. _includes:
+.. _`#include`:
+
+``#include``
+------------
+
+To reuse common parts of template text across template files, you can include
+other files using the ``#include`` directive::
+
+  #include "base.txt"
+
+Any content included this way is inserted into the generated output. The
+included template sees the context data as it exists at the point of the
+include. `Macros`_ in the included template are also available to the including
+template after the point it was included.
+
+Include paths are relative to the filename of the template currently being
+processed. So if the example above was in the file "``myapp/mail.txt``"
+(relative to the template search path), the include directive would look for
+the included file at "``myapp/base.txt``". You can also use Unix-style
+relative paths, for example "``../base.txt``" to look in the parent directory.
+
+Just like other directives, the argument to the ``#include`` directive accepts
+any Python expression, so the path to the included template can be determined
+dynamically::
+
+  #include '%s.txt' % filename
+
+Note that a ``TemplateNotFound`` exception is raised if an included file can't
+be found.
+
+.. note:: The include directive for text templates was added in Genshi 0.5.
+
+
 Variable Binding
 ================
 
Copyright (C) 2012-2017 Edgewall Software