Home Wendy
Web engine software

Wendy Home Page / Docs / Templates
 download   mods   docs   contact 
 

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.

Macros

Macros are simple text replaces. Inside templates they written as name (all caps) in square brackets. Example:

<html><head> <title> [PAGE_TITLE] </title> ...

Keywords

Keywords 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:

CODE
CTYPE
HEADER
INCLUDE
      LOAD
PROC
TEMPLATE
TEMPLATEC
      TEMPLATEFF
TTL
URL
URLFF

CODE

Sets http response code. Example:

...
CODE:403
...

Top

CTYPE

Sets output content type. Default is text/html. To return text/html or text/css, example:

CTYPE:text/css
.colored
{
background-color:#dddddd;
color:#000000;
}
...

Top

HEADER

Add a custom header to server output. May appear several times. Example:

HEADER:X-My-Page:true
...
HEADER:Set-Cookie: a=b,domain=mydomain.com
...

Top

INCLUDE

Includes a file from templates directory (<wendy>/var/hosts/<hostname>/tpl). File not parsed for keywords inside. See TEMPLATE keyword. Example:

...
INCLUDE:static_footer
...

Top

LOAD

Load 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:<> addresses

These addresses are special. They let you use some internal Wendy information as macros contents.

  • SYSTEM:lng

    Adds [ WENDY_LNG ] and [ WENDY_LNG_ID ] with language string and id respectively.

  • SYSTEM:envq

    All environment variables, quoted with XML::Quote, with WENDY_ENV_ prefix. WENDY_ENV_HOST contains actual name of current host, WENDY_ENV_HTTP_HOST contains name from request (may be alias).

Top

PROC

Execute 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" }.

Top

TEMPLATE

Same 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>
...

Top

TEMPLATEC

TEMPLATEC(ached).

Top

TEMPLATEFF

TEMPLATEF(ull)F(eatured) - custom ctype, headers and codes (if any) from this template are not ignored.

Top

TTL

Set 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
...

Top

URL

Tells Wendy to go download an external URL and paste its output. Example:

...
URL:http://www.otherhost.com/
...

Top

URLFF

URLF(ull)F(eatured) - same as URL, but Content-Type also set to that returned by URL.

Top

eugene kuzin, 2007-2011