Opened 15 years ago
Last modified 7 years ago
#296 new enhancement
py:element directive — at Version 2
Reported by: | Arc Riley <arcriley@…> | Owned by: | cmlenz |
---|---|---|---|
Priority: | minor | Milestone: | 0.9 |
Component: | Template processing | Version: | 0.5.1 |
Keywords: | Cc: |
Description (last modified by cmlenz)
Currently to generate elements from a list some hackery is needed, ie:
<?python from genshi.builder import tag ?> <py:for each='field in fields'> ${getattr(tag,field)} </py:for>
It would be cleaner if we could instead:
<py:for each='field in fields'> <py:element name="field"/> </py:for>
py:attrs should be applied second such that:
<py:for each='field in fields'> <py:element name='field' py:attrs='fields[field]'/> </py:for>
It would be useful if the element name could contain the namespace, ie:
fields = {'greek:alpha' : {'value' : 1, 'xmlns:greek' = 'xml:foo:greek'}, 'game:monsters' : {'hp' : 552, 'label' : 'Queen Banshee'}}
In XMPP there are many cases where it'd be useful for generated elements to be in different namespaces like this. A separate py:element namespace= attribute may also be useful in some situations but would increase complexity in the above examples.
Change History (2)
comment:1 Changed 15 years ago by cmlenz
- Description modified (diff)
comment:2 Changed 15 years ago by cmlenz
- Description modified (diff)
Note: See
TracTickets for help on using
tickets.
(add some formatting to the description)