Edgewall Software

Changes between Version 16 and Version 17 of MarkupTemplates


Ignore:
Timestamp:
Jul 11, 2006, 4:54:53 PM (18 years ago)
Author:
cmlenz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MarkupTemplates

    v16 v17  
    236236
    237237== Template Includes ==
     238
     239To reuse common snippets of template code, you can include other files using [http://www.w3.org/TR/xinclude/ XInclude].
     240
     241For this, you need to declare the XInclude namespace (commonly bound to the prefix "xi") and use the `<xi:include>` element where you want the external file to be pulled in:
     242
     243{{{
     244<html xmlns="http://www.w3.org/1999/xhtml"
     245      xmlns:py="http://markup.edgewall.org/"
     246      xmlns:xi="http://www.w3.org/2001/XInclude">
     247  <xi:include href="base.html" />
     248  ...
     249</html>
     250}}}
     251
     252Include paths are relative to the filename of the template currently being processed. So if the example above was in the file "`myapp/index.html`" (relative to the template search path), the XInclude processor would look for the included file at "`myapp/base.html`". You can also use Unix-style relative paths, for example "`../base.html`" to look in the parent directory.
     253
     254By default, an error will be raised if an included file is not found. If that's not what you want, you can specify fallback content that should be used if the include fails. For example, to to make the include above fail silently, you'd write:
     255
     256{{{
     257  <xi:include href="base.html"><xi:fallback /></xi:include>
     258}}}
     259
     260See the [http://www.w3.org/TR/xinclude/ XInclude specification] for more about fallback content. Note though that Markup currently only supports a small subset of XInclude.