[Twisted-web] operating on literals in nevow html templates

indigo at bitglue.com indigo at bitglue.com
Tue Apr 13 14:48:19 MDT 2004


If you can add n:render='dynamicPopup' to any links you want to process,
then you can access the href attribute of that tag with
"context.tag.attributes['href']" within your render method. To change
it, first clone context.tag, modify the clone, and then return it, like
so:

def render_dynamicCall( self, context, data ):
  copy = context.tag.clone()
  href = copy.attributes['href']
  # modify href to your liking
  copy.attributes['href'] = href
  return copy

On Mon, Apr 12, 2004 at 04:59:02PM -0400, Joe Bowers wrote:
> I'm using Nevow along with designers who use a 
> WYSIWYG HTML editor, and it's working like a dream!
> However, I've run into an interesting scenario,
> and I was wondering if anyone has any advice or
> best practices to recommend.
> 
> I would like to perform a transformation
> something like the following in my completed
> code:
> 
> <a href="GUI_GENERATED_CALL(garbage, 'WindowName', 'WindowParams')"
>    >Click here for a popup</a>
> 
> to
> 
> <a href="dynamicCall('dynamicData', 'WindowName', 'WindowParams')"
>    >Click here for a popup</a>
> 
> It's acceptable for me to bend, fold, or otherwise
> mutilate the designer-provided tag to some degree, so
> something like:
> 
> <a href="GUI_GENERATED_CALL(garbage, 'WindowName', 'WindowParams')"
>    nevow:data="{'name' : 'WindowName', 'params' : 'WindowParams'}"
>    nevow:render="dynamicPopup"
>    >Click here for a popup</a>
> 
> would be fine- but the literal parameters I need to
> preserve need to be under the control of the designers
> and present in the template rather than in the code.
> 
> Any advice or pointers on how this sort of thing 
> should be handled?
> 
> Thanks for your help!
> 
> --------------------
> Joe Bowers
> Technical Director
> Seventy-two dpi
> 
> 828.252.2408 [x308]
> joe at seventytwodpi.com
> http://www.seventytwodpi.com



More information about the Twisted-web mailing list