comparison pspx.html @ 39:ee19984ba31d draft

Merge in the header-includes branch to the trunk.
author David Barts <n5jrn@me.com>
date Tue, 28 May 2019 20:20:19 -0700
parents 336bc2f622e4
children
comparison
equal deleted inserted replaced
23:e8b6ee7e5b6b 39:ee19984ba31d
35 is resolved at route-creation time; no extra processing will happen at 35 is resolved at route-creation time; no extra processing will happen at
36 request time.</dd> 36 request time.</dd>
37 <dt><code>#hidden</code></dt> 37 <dt><code>#hidden</code></dt>
38 <dd>This is a hidden page; do not create a route for it. The page can only 38 <dd>This is a hidden page; do not create a route for it. The page can only
39 be displayed by a forward.</dd> 39 be displayed by a forward.</dd>
40 <dt><code>#load</code></dt>
41 <dd>Load the specified Chameleon template file and make the loaded
42 template available as a template variable. Useful for importing and
43 invoking macros. See the section on this directive below for more
44 information.</dd>
40 <dt><code>#methods</code></dt> 45 <dt><code>#methods</code></dt>
41 <dd>A list of HTTP request methods, separated by whitespace, follows. The 46 <dd>A list of HTTP request methods, separated by whitespace, follows. The
42 route will allow all specified methods. Not specifying this line is 47 route will allow all specified methods. Not specifying this line is
43 equivalent to specifying <code>#methods GET</code>.</dd> 48 equivalent to specifying <code>#methods GET</code>.</dd>
44 <dt><code>#python</code></dt> 49 <dt><code>#python</code></dt>
72 error code is undefined; doing so is best avoided.</p> 77 error code is undefined; doing so is best avoided.</p>
73 <h3>Templates with No Code-Behind</h3> 78 <h3>Templates with No Code-Behind</h3>
74 <p>Code-behind is optional for both normal and error page templates. If 79 <p>Code-behind is optional for both normal and error page templates. If
75 code-behind is not provided, TinCan will use the <var>Page</var> or <var>ErrorPage</var> 80 code-behind is not provided, TinCan will use the <var>Page</var> or <var>ErrorPage</var>
76 class as appropriate. </p> 81 class as appropriate. </p>
82 <h3>Loading Templates</h3>
83 <p>The <code>#load</code> directive may be used to load additional
84 templates, e.g. ones containing macro definitions. Note that the loaded
85 files are standard Chameleon templates and <em>not</em> TinCan <code>.pspx</code>
86 files (i.e. they cannot contain any header directives); as such, loaded
87 files must have the standard <var>.pt</var> extension for Chameleon
88 template files.</p>
89 <p>In the normal case, typing <code>#load foo.pt</code> will load a file
90 relative to the same directory as the page containing the <code>#load</code>
91 directive itself. The loaded template object will be made available as a
92 template variable matching the file name sans extension (in this case, <samp>foo</samp>).
93 One can change the name of the variable created by prefixing the file
94 specification with a variable name followed by an equals sign,
95 e.g. <code>#load t=foo.pt</code>. If one places the specification inside
96 angle brackets (e.g. <code>#load &lt;t=foo.pt&gt;</code>), loaded files
97 are searched for in <code>WEB-INF/tlib</code> instead.</p>
98 <p>Finally, as is allowed for all arguments to header directives, one may
99 enclose the argument to #load inside single or double quotes and use the
100 normal Python backslash escaping.</p>
101 <h3>Using Loaded Macros</h3>
102 <p>Once a template has been loaded, it will be available as a sub-attribute
103 of the <var>macros</var> attribute of the associated template object.
104 E.g.:</p>
105 <pre>#load foo.pt<br>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br> &lt;head&gt;<br> &lt;title&gt;Macro Example&lt;/title&gt;<br> &lt;/head&gt;&lt;body&gt;<br> &lt;p metal:use-macro="foo.macros.bar"&gt;&lt;/p&gt;<br> &lt;/body&gt;<br>&lt;/html&gt;</pre>
77 <h2>The Body</h2> 106 <h2>The Body</h2>
78 <p>The body begins with the first line that <em>does not</em> start with <code>#</code> 107 <p>The body begins with the first line that <em>does not</em> start with <code>#</code>
79 (or the first line after the <code>#end</code> directive, whichever comes 108 (or the first line after the <code>#end</code> directive, whichever comes
80 first) and has the exact same syntax that the templates are in for this 109 first) and has the exact same syntax that the templates are in for this
81 webapp. By default, Chameleon templates are used. Cheetah, Jinja2, Mako, 110 webapp. By default, Chameleon templates are used. Cheetah, Jinja2, Mako,