[albatross-users] Re: css

Dave Cole djc at object-craft.com.au
Sat Mar 16 10:20:23 EST 2002


>>>>> "Lewis" == Lewis Bergman <lbergman at abi.tconline.net> writes:

Lewis> I hate to bother whoever gets this but I was wondering about
Lewis> css.  As I am making my way through the different al-input tags
Lewis> I see no way of enabling some kind of css identifier like
Lewis> class= or id=. I was hoping to be able to at least use class so
Lewis> that I might differentiate different input fields pased on type
Lewis> or status.

Lewis> For instance, I like to use a light blue background for any
Lewis> text entry that is a db search input. Using css and something
Lewis> like class=srch makes this easy. I also like to use a
Lewis> background of light yellow for any field that failed some
Lewis> verification text after changing the class type to class=err.

Lewis> This might be out of the scope of albatross but I thought I
Lewis> would ask first.  Maybe there is some other way to do this that
Lewis> I haven't thought of yet.  Thanks again for the great package.

Oops...  The documentation doesn't seem to mention this but any tag
attributes not recognised by Albatross are passed through to the
output unmodified.

The following passes a class attribute through <al-input>

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>>> import albatross
>>> ctx = albatross.SimpleContext('.')
>>> ctx.locals.names = ['John', 'Terry', 'Eric']
>>> albatross.Template(ctx, '<magic>', '''
... <al-for iter="i" expr="range(len(names))">
...  <al-input nameexpr="'names[%d]' % i.value()" whitespace class="fancy">
... </al-for>
... ''').to_html(ctx)
>>> ctx.flush_content()
<input class="fancy" name="names[0]" value="John">
<input class="fancy" name="names[1]" value="Terry">
<input class="fancy" name="names[2]" value="Eric">
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

This does not directly solve your problem of needing to alter the
value of the class attribute, but you can always use
<al-if><al-else></al-if> to select between normal and error variants
of the tag.

- Dave

-- 
http://www.object-craft.com.au




More information about the Albatross-users mailing list