<ul> {%REPEAT% FeedItems} <li> <a href="{%ITEM-METADATA% url}"> {%ITEM-METADATA% name} </a> {%/REPEAT%} </ul>{%REPEAT% FeedItems%} instructs Awasu to repeat through each feed item and as it does so, {%ITEM-METADATA% url} and {%ITEM-METADATA% name} will be replaced with the current item's URL and name respectively.
Metadata is stored in a tree-like hierarchy, so a channel's metadata might look something like this:
* | +-- Name The channel's name +-- Description The channel's description +-- Link | | | +-- URL The channel's home page URL | +-- Author | +-- Name The author's name. +-- Email The author's email address. +-- URL The author's home pageThese are accessed using the {%CHANNEL-METADATA%} parameter and so you could create a link to the author's home page like this:
<a href="mailto:{%CHANNEL-METADATA% author/url}"> {%CHANNEL-METADATA% author} </a>
Entries in the metadata hierarchy are either metadata values (e.g. Name or URL in the example above) or metadata groups (e.g. Link or Author). Metadata groups have no actual value themselves but if they are used in template parameters (e.g. {%CHANNEL-METADATA% author}) then Awasu will check the child metadata values and choose the most appropriate one.
So, in the example above, Awasu will generate a
{%?xxx%} tests if the xxx parameter has been set and if so, generates the output up to the next {%ENDIF%} tag. {%!xxx%} does the opposite, generating output if the parameter has not been set. Both of these can also have an {%ELSE%} clause.
The following example checks if a feed item has an author. If it does, it outputs the author's name (or if not present, email address or URL), wrapped in a mailto: link if the author's email address has been given.
{%?CHANNEL-METADATA% author} test if the channel has specified an author {%?CHANNEL-METADATA% author/email} test if the author's email address was given <a href="mailto:{%@%}"> yes - start the mailto: link {%ENDIF%} {%CHANNEL-METADATA% author} insert the author's name/email/URL {%?CHANNEL-METADATA% author/email} test if the author's email address was given </a> yes - close the mailto: link {%ENDIF%} {%ELSE%} No author was specified! insert this if no channel author was specified {%ENDIF%}{%@%} is a shorthand for the parameter evaluated in the previous {%?xxx%} tag.
<a href="mailto:joe@blow.com"> Joe<Blow </a>and the < character will cause problems in an HTML browser.
Awasu automatically handles this by checking the extension of the output file and encoding values appropriately. However, there are some cases where the default handling is not enough and so you can force encoding by adding encode and chars attributes to the template parameter. For example:
{%CHANNEL-METADATA% author encode=sgml chars=<&"}This insert the channel's author but SGML-encodes the three special characters specified.
The encode attribute may have the values sgml, percent or none. For SGML encoding, the default characters encoded are < and & while for percent encoding, only the % character is encoded by default.
The example above also suffers from the same problem when generating the mailto: link if the email address contains a " character. The code below shows how both these issues can be fixed:
{%?CHANNEL-METADATA% author} {%?CHANNEL-METADATA% author/email} <a href="mailto:{%@% encode=sgml chars=<&\"}"> {%ENDIF%} {%CHANNEL-METADATA% author encode=sgml chars=<&\"} {%?CHANNEL-METADATA% author/email} </a> {%ENDIF%} {%ELSE%} No author was specified! {%ENDIF%}
Similarly, feed items can have more than one author. The example above doesn't use the {%REPEAT% xxx} tag and so just shows the first author. To show all the authors, the code must be wrapped in a {%REPEAT% xxx} tag like this:
{%?CHANNEL-METADATA% author} {%REPEAT% author} {%?CHANNEL-METADATA% author/email} <a href="mailto:{%@% encode=sgml chars=<&\"}"> {%ENDIF%} {%CHANNEL-METADATA% author encode=sgml chars=<&\"} {%?CHANNEL-METADATA% author/email} </a> {%ENDIF%} {%ELSE%} No author was specified! {%/REPEAT%} {%ENDIF%}Awasu repeatedly tests if there is another author metadata value, outputting each author's name, wrapped in a mailto: link if an email address was provided.
<html> <head> {%INCLUDE% includes/StandardHead.include} <style> {%INCLUDE% Rusty.css} {%INCLUDE% Rusty.user.css isOptional} </style> </head> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <body> {%INCLUDE% includes/StandardBody.include} </body> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> </html>The {%BASE-DIR%} template parameter is adjusted each time to point to the directory that the template file currently being processed lives in. This allows template files to reference external resources such as images e.g. from Rusty.css:
.banner { background-image: url( "file://{%BASE-DIR%}/images/Rusty/banner.png" ) ; background-repeat: repeat-x ; border: 3px double ; padding: 10px ; color: #fff ; }