Discussion:
[albatross-users] al-if and al-setarg
Alan Meadows
2006-04-11 18:31:38 UTC
Permalink
Hello Albatross users,

I was trying to wrap an al-if around an al-setarg today in a template and
ran into trouble. Here is what I was trying to do:

<al-expand name="form">

<al-setarg name="title">Create Additional SPF Record</al-setarg>

<al-setarg name="desc">Enter an additional SPF records for this
domain below.</al-setarg>

<al-setarg name="fields">

<al-expand name="forminput">
<al-if expr="spftype == 'ip4'">
<al-setarg name="label">IP
Address/Range</al-setarg>
<al-else>
<al-setarg name="label">Hostname</al-setarg>
</al-if>
</al-expand>

</al-setarg>

</al-expand>

Albatross produced the following error:

HTML Traceback:

File "lib/includes/forminput", line 7, in al-macro
<al-macro name="forminput">
File "lib/includes/forminput", line 15, in al-usearg
<td valign="center" align="right"><b><al-usearg
name="label"></b></td>

Python Traceback:

File "/usr/lib/python2.4/site-packages/albatross/context.py", line 127, in
get_macro_arg
raise ApplicationError('undefined macro argument "%s"' % name)
ApplicationError: undefined macro argument "label"

I was able to make it work by moving the al-if higher up the chain, but I
think the template becomes a little more redundant and harder to read:

<al-expand name="form">

<al-setarg name="title">Create Additional SPF Record</al-setarg>

<al-setarg name="desc">Enter an additional SPF records for this
domain below.</al-setarg>

<al-setarg name="fields">

<al-if expr="spftype == 'ip4'">
<al-expand name="forminput">
<al-setarg name="label">IP
Address/Range</al-setarg>
<al-setarg name="input"><al-input
type="text" name="spfdata" length="30"></al-setarg>
</al-expand>
<al-else>
<al-expand name="forminput">
<al-setarg name="label">Hostname</al-setarg>
<al-setarg name="input"><al-input
type="text" name="spfdata" length="30"></al-setarg>
</al-expand>
</al-if>

</al-setarg>

</al-expand>

Is there something I can do about this? Am I approaching this the wrong way?

Thanks!

Alan
Gabriel Cooper
2006-04-11 18:42:21 UTC
Permalink
Post by Alan Meadows
<al-expand name="forminput">
<al-if expr="spftype == 'ip4'">
<al-setarg name="label">IP
Address/Range</al-setarg>
<al-else>
<al-setarg
name="label">Hostname</al-setarg>
</al-if>
</al-expand>
<al-expand name="forminput">
<al-setarg name="label">
<al-if expr="spftype == 'ip4'">
IP Address/Range
<al-else>
Hostname
</al-if>
</al-setarg>
</al-expand>

Loading...