# HG changeset patch # User David Barts # Date 1559099830 25200 # Node ID 336bc2f622e43ff87a3edfa1235a0d49fae08ceb # Parent ce67eac10fc72610ecd742b80a36df27f4730cc3 Preliminary revisions to some draft documentation. diff -r ce67eac10fc7 -r 336bc2f622e4 pspx.html --- a/pspx.html Tue May 28 17:08:36 2019 -0700 +++ b/pspx.html Tue May 28 20:17:10 2019 -0700 @@ -37,6 +37,11 @@
#hidden
This is a hidden page; do not create a route for it. The page can only be displayed by a forward.
+
#load
+
Load the specified Chameleon template file and make the loaded + template available as a template variable. Useful for importing and + invoking macros. See the section on this directive below for more + information.
#methods
A list of HTTP request methods, separated by whitespace, follows. The route will allow all specified methods. Not specifying this line is @@ -74,6 +79,30 @@

Code-behind is optional for both normal and error page templates. If code-behind is not provided, TinCan will use the Page or ErrorPage class as appropriate.

+

Loading Templates

+

The #load directive may be used to load additional + templates, e.g. ones containing macro definitions. Note that the loaded + files are standard Chameleon templates and not TinCan .pspx + files (i.e. they cannot contain any header directives); as such, loaded + files must have the standard .pt extension for Chameleon + template files.

+

In the normal case, typing #load foo.pt will load a file + relative to the same directory as the page containing the #load + directive itself. The loaded template object will be made available as a + template variable matching the file name sans extension (in this case, foo). + One can change the name of the variable created by prefixing the file + specification with a variable name followed by an equals sign, + e.g. #load t=foo.pt. If one places the specification inside + angle brackets (e.g. #load <t=foo.pt>), loaded files + are searched for in WEB-INF/tlib instead.

+

Finally, as is allowed for all arguments to header directives, one may + enclose the argument to #load inside single or double quotes and use the + normal Python backslash escaping.

+

Using Loaded Macros

+

Once a template has been loaded, it will be available as a sub-attribute + of the macros attribute of the associated template object. + E.g.:

+
#load foo.pt
<!DOCTYPE html>
<html>
<head>
<title>Macro Example</title>
</head><body>
<p metal:use-macro="foo.macros.bar"></p>
</body>
</html>

The Body

The body begins with the first line that does not start with # (or the first line after the #end directive, whichever comes