Template Syntax Primer
Template Tags
There are a number of ways to write a template tag. Let's have a look at them.
<r:i name="common.blueprint"/>
${i common.blueprint/}
[!I 'common.blueprint'/]
See the difference? Now all of these were using the shorthand syntax. What about those tags with some content?
Thank you!
<r:b name="myblock">Thank you!</r:b>
${b myblock}Thank you!${/b}
[!B 'myblock']Thank you![!/B]
And that's basically all there is to it. Please note, that they are all equivalent, it's just syntactic sugar. Now, you might wonder about the pro's and con's of those syntax variations. Well, just use what works best for you. Personally, I like using one of the shorter syntaxes, but if you have an editor that prefers those html-style tags, by all means, use them. Also, if you have a seperate team of designers working on the project, let them decide.
There's a lot more information about these different tags here: Alternative tag syntax
Including other templates
Ok, so you have a template and you want to include another template right in there? That's exactly what the I-Tag does. Here's an example:
<r:i name="common.header"/>
<h1>Guestbook</h1>
<p>Hi, here you will find my Guestbook. It will be the best Guestbook ever, as soon as I have got this RIFE thing figured out.</p>
<r:i name="common.footer"/>
So the templates common.header and common.footer will probably contain the usual <html><head><title>Some retarded title</title></head><body> and </body></html> stuff, maybe plus a little layout.
Value placeholders
Ok, here follows the next lesson, the value tag. For explanation purposes, I wrote this short snippet that might have come from a RIFE template:
<p>Today, we are going to be at <r:v name="location"/> around lunchtime. Feel free to join us!</p>
<p>Here is a list of other places we are going to visit in the next few days. Stay tuned!</p>
<r:v name="list_places"/>
So, in this short example, we have two Values. The first one contains the location these people are going to visit and the second one will probably contain quite a bit of HTML code listing all the other future venues they might go to. What I want to show you, that often your values will be more than one word or one sentence. Values can be blocks or even pages of code, so don't limit yourself in your thinking there. We'll see why later on.
Oh and the values are assigned through your Java code. Typically from within the Element Definition.
todo: default values
Blockvalues
Sometimes you want to assign a value right from within a template, for example to have a default that might be overwritten from the code, but not necessarily. Let's have an example for this:
<h1>Status</h1>
<p><r:v name="status_message"/></p>
<r:bv name="status_message">Everything is fine.</r:bv>
When the blockvalue tag is parsed, it's content is taken and assigned to the value with the corresponding name.
Blocks
In order to explain blocks I just extend the previous example a bit.
<h1>Status</h1>
<h1>Status</h1>
<p><r:v name="status_message"/></p>
<r:bv name="status_message">Everything is fine.</r:bv>
<r:b name="file_not_found_message">The file was not found.</r:b>
Now, when the file is not found our Java code can just replace status_message with the contents of file_not_found_message.
Putting it all together
Here is a more complex example witch utilizes all four tags.
<r:i name="common.blueprint"/>
<r:bv name="window_title">Our Plans for today</r:bv>
<r:bv name="content">
<p>Today, we are going to be at <r:v name="location"/> around lunchtime. Feel free to join us!</p>
<p>Here is a list of other places we are going to visit in the next few days. Stay tuned!</p>
<table>
<tr><th>Day</th><th>Name of Location</th></tr>
<r:v name="list_places"/>
</table>
</r:bv>
<r:b name="list_places_row">
<tr>
<td><r:v name="day"/></td><td><r:v name="place"/></td>
</tr>
</r:b>
todo: description