3.5.2 Single Argument Macros

##
3.5.2 Single Argument Macros

The single argument macro is almost as simple as the zero argument macro. You should always use the unnamed argument to pass content to a single argument macro.

If you look at news sites such as http://slashdot.org/ you will note that they make heavy use of HTML tricks to improve the presentation of their pages. Single argument macros can be extremely useful in simplifying your template files by moving the complicated HTML tricks into a separate macro definition file.

Let's look at the top story at http://slashdot.org/ to illustrate the point. The title bar for the story is constructed with the following HTML (reformatted so it will fit on the page).

    <table width="100%" cellpadding=0 cellspacing=0 border=0>
    <tr>
    <td valign=top bgcolor="#006666">
    <img src="http://images.slashdot.org/slc.gif" width=13 height=16 alt="" align=top>
    <font size=4 color="#FFFFFF" face="arial,helvetica">
    <b>Another Nasty Outlook Virus Strikes</b>
    </font>
    </td>
    </tr>
    </table>

As you can see, most of the HTML is dedicated to achieving a certain effect. If you were using Albatross to construct the same HTML you would probably create a macro called `story-title` like this:

    <al-macro name="story-title">
    <table width="100%" cellpadding=0 cellspacing=0 border=0>
    <tr>
    <td valign=top bgcolor="#006666">
    <img src="http://images.slashdot.org/slc.gif" width=13 height=16 alt="" align=top>
    <font size=4 color="#FFFFFF" face="arial,helvetica">
    <b><al-usearg></b>
    </font>
    </td>
    </tr>
    </table>
    </al-macro>

Then you could generate the story title HTML like this:

    <al-expand name="story-title">Another Nasty Outlook Virus Strikes</al-expand>

Since stories are likely to be generated from some sort of database it is more likely that you would use something like this:

    <al-expand name="story-title"><al-value expr="story.title"></al-expand>