<!---->
<?xml-stylesheet href="template.xsl" type="text/xsl"?>
<document cache-methods="get,post">
<title>Gnomon Template Sample</title>
<body>
<heading>Gnomon Template Sample</heading>
<sub-heading>What is a template?</sub-heading>
<paragraph>
Gnomon has the ability to split POST data and return that data to individual
included templates. Templates are typically written in some dynamic language
(ASP/ASP.NET/CGI/etc), due to the need to process the data in some way.
</paragraph>
<paragraph>
The template functionality works by included a hidden field, gnomon-multipart-form
which should have a value of "1" for field splitting to take place. Your XSLT should
then rewrite the names of form elements in the final output to template-id_field, e.g.
say you have:
<sample>
<input name="user_name" />
</sample>
And this is include in the template with ID #4, the XSLT should output:
<sample>
<input name="4_user_name" />
</sample>
(Take a look at the source for this page for a full example).
</paragraph>
<paragraph>
Gnomon also has the ability to pass parameters to included templates. These parameters
are passed in the form of a special header, X-Gnomon-Parameters, as documented in
<link linkend="/gnomon/manual/manual.html">the manual</link>. An object is
provided to make these easily accessible from ASP; other languages will have to parse
the parameters header themselves (it is likely that an object for ASP.NET will be
added in future). The sample simply passes the name of the template include file
in. In general, parameters are used to provide a way to control the behaviour of the
template. Note that the special parameter template-id always exists.
</paragraph>
<paragraph>
See the source for:
<itemizedlist>
<listitem><xml-source-link new-window="1" href="/gnomon/samples/template/template.xml">This file, the top level template.</xml-source-link></listitem>
<listitem><xml-source-link new-window="1" href="/gnomon/samples/template/user-details.xml">The user details form.</xml-source-link></listitem>
<listitem><xml-source-link new-window="1" href="/gnomon/samples/template/user-preferences.xml">The user preferences form.</xml-source-link></listitem>
</itemizedlist>
</paragraph>
<sub-heading>User details</sub-heading>
<include-template href="user-details.xml" />
<sub-heading>User preferences</sub-heading>
<include-template href="user-preferences.xml" />
<input name="hello" type="submit" />
</body>
</document>