Scott Parish wrote:
I have a dtml-var tag that is being repeated over and over inside of a dtml-in tag. I would like the client to be able to custimize the maximum amount of text output they see, so i did something like the following:
<dtml-var "item['title']" size="getTitleLen()">
Where getTitleLen is a method which returns an integer of how many characters max the title is to be. However, when i have this dtml method rendered, i get the following error:
a size attribute was used in a var tag with a non-integer value.
Looks like you'll need to patch lib/python/DocumentTemplate/DT_Var.py to get this working. 326,328c326,331 < except: raise 'Document Error',( < '''a <code>size</code> attribute was used in a <code>var</code> < tag with a non-integer value.''') ---
except: try: size=atoi(str(md[size])) except: raise 'Document Error',( '''a <code>size</code> attribute was used in a <code>var</code> tag with a non-integer value.''')
After this patch, you can use normal numeric literals, or you can use values from the namespace. Here's an example: index_html dtml-method: ---- <dtml-var standard_html_header> <h2><dtml-var title_or_id></h2> <p> This is the <dtml-var id> Document. </p> <dtml-var "'Hello world'" size="getLen"> <dtml-var standard_html_footer> ---- getLen dtml-method: ---- <dtml-return "5"> ---- -- Steve Alexander Software Engineer Cat-Box limited