[albatross-users] Some questions and my albatross wrapper....

Gabriel Cooper gabriel.cooper at mediapulse.com
Fri Feb 24 07:37:42 EST 2006


>For loops with var="foo"?
>-------------------------
>I keep using for loops and I keep needing 'iter.value()' all through my
>templates which is ugly and kind of annoying. (I tend to use the
>object more than the iterator, but maybe thats just me.)
>  
>
Given that one necessarily desires readable over concise code (otherwise 
we'd be in the PERL forums, no?), I always found that my first line 
after a for loop was:

<al-exec expr="descriptive, variable, name, here = iter.value()"/>

This was a constant annoyance I had with Albatross, so we did exactly 
what you suggested when we created Snakeskin and implemented it like so:

<al-for expr="[('bob','smith'),('jane','doe'),]"
    iter="iter"
    expand="(first_name,last_name)">
...

where the "expand" parameter expands the list given into locals.

Seems to work pretty well. I suppose we could make naming the iterator 
optional as well... I've found use for it on count() and so on, so I 
like to keep it around. =D


>
>
>Templates?
>----------
>I love my albatross :), but what I want is for a single meta-template
>over my whole site. Currently I have the following in all my
>tempaltes:
>
>  <al-expand name="header"/>
>  <al-form method="post">
>  **my stuff**
>  </al-form>
>  <al-expand name="footer"/>
>  
>
here's an overly complicated example of what I usually end up with.

<al-expand name="subpage_template" onload="someLoadEvent();" 
title="custom title">
<al-setarg name="head">
[some javascript function named someLoadEvent() to extend the example =P]
</al-setarg>
put html page content here
</al-expand>

with the following for subpage_template:

<al-macro name="subpage_template" head="" onload="" title="Default 
Title" meta_description="my website is for people that...">
    <html><head><al-usearg name="head"/></head>
    <title><al-usearg name="title"/></title>
    <body onload="<al-usearg name="body"/>">
    [site structure specific to this template....]
    <al-expand name="generic_site_header"/>
    [finish structure specific to this template]

    <al-usearg/> (<--- expands the content given in the body of the 
"al-expand" tag)

    [call various other common macros... footer...privacy policy... 
copyright... terms of use... etc. etc.]
</al-macro>

Actually... It's been a while since I used the original Albatross. Does 
it let you set default macro parameters? If not, move the parameters in 
the al-macro tag other than "name" to each individual al-expand call and 
I think move the parameters (once again, other than "name") out of the 
al-expand into their own <setarg> tags.

Gabriel.






More information about the Albatross-users mailing list