Wendy Web engine software Wendy Home Page / Docs / Templates |
This document describes Wendy template syntax. Templates are just plain HTML or Text files. Template contents passed to output unmodified, except for reserved keywords and macros names. MacrosMacros are simple text replaces. Inside templates they written as name (all caps) in square brackets. Example:
<html><head>
<title>
[PAGE_TITLE]
</title>
...
KeywordsKeywords are some special directives. They tell Wendy how to process templates, where from to load macros, for how long can template be cached, etc. Keywords must be written one at the line, no other code should present on same line. Example:
<html><head>
<title> PROC:form_title </title> ... All keywords are described below:
CODESets http response code. Example:
...
CODE:403 ... CTYPESets output content type. Default is text/html. To return text/html or text/css, example:
CTYPE:text/css
.colored { background-color:#dddddd; color:#000000; } ... HEADERAdd a custom header to server output. May appear several times. Example:
HEADER:X-My-Page:true
... HEADER:Set-Cookie: a=b,domain=mydomain.com ... INCLUDEIncludes a file from templates directory (<wendy>/var/hosts/<hostname>/tpl). File not parsed for keywords inside. See TEMPLATE keyword. Example:
...
INCLUDE:static_footer ... LOADLoad macros from another address (but current host). Example:
...
LOAD:my_fancy_address ... LOAD:_this - re-loads macros for current address. Useful when some macros loaded from another address have overwritten ones from "this". LOAD:<host>:<addr>Since 20080411 oher host macroses can be loaded. Cant use aliases here. Example:
...
LOAD:www.host.com:my_fancy_address ... LOAD:SYSTEM:<> addressesThese addresses are special. They let you use some internal Wendy information as macros contents.
PROCExecute Perl procedure. See "Procedures" section in admin interface. Procedure output (plain scalar), if any, placed in exchange for calling string. Example:
<tt>
PROC:rand_num </tt> ... Will look something like this:
<tt>
21.218346513264 </tt> ... when processed. There is also a way to pass arguments to procedures:
<tt>
PROC:test_proc:ARGUMENTS_STRING </tt> ... test_proc is called, ARGUMENTS_STRING passed as $ENV{ "WENDY_PROC_ARGS" }. TEMPLATESame as INCLUDE, but more advanced (and slow), as keywords and macros are processed inside. Only data field used in output, to inherit ctype and others use TEMPLATEFF. All TEMPLATE* keywords can be used with host name to process template from other host. Example
<tt>
TEMPLATE:www.host.com:my_fancy_address </tt> ... TEMPLATECTEMPLATEC(ached). TEMPLATEFFTEMPLATEF(ull)F(eatured) - custom ctype, headers and codes (if any) from this template are not ignored. TTLSet cache time (in seconds) for output. By default, page or template (if included with TEMPLATEC) gets cached forever. Ttl = 0 means no cache. Example:
...
TTL:600 ... URLTells Wendy to go download an external URL and paste its output. Example:
...
URL:http://www.otherhost.com/ ... URLFFURLF(ull)F(eatured) - same as URL, but Content-Type also set to that returned by URL.
|