FrontPage
»
EvolutionaryProposals
»
NamedDTMLInLoop
Named DTML-In Loop Proposal
- Jim
- Note that this proposal applies to all dtml tags that introduce new variables (e.g. the tree tag).
Poster Child:
<dtml-in SQL1 var=s1><dtml-in SQL2 var=s2> <dtml-if expr="s1.key == s2.key"> <dtml-var s1/name> is the same as <dtml-var s2/name>; </dtml-if> </dtml-in></dtml-in>
Goals
- Make DTML-In variables such as
sequence-item
easier and more natural to use in expressions. - Allow namespaces of nested DTML-In tags to be easily separated and separately accessed.
Proposed Changes
Add an optional argument to DTML-In which declares a loop object.
This wouldn't affect the standard (sequence-item
) syntax, but would
add an object to the namespace through which all of the loop variables
could be accessed. The attribute names of the loop object would use
underscores (_) in place of hyphens.
Implement PathNameTraversal.
Result
This would allow loop variables to be distinguished by prepending the loop object name to them, with a slash (/) in DTML names or a dot (.) in expressions.
Example:
<dtml-in first_sequence var=outer>; <dtml-in second_sequence var=inner> The following should all produce the same result: <dtml-var sequence-item> <dtml-var expr="_['sequence_item']"> <dtml-var inner/sequence-item> <dtml-var expr="inner.sequence_item"> We can also access variables from the outer loop, like so: <dtml-var outer/sequence-item> <dtml-var expr="outer.sequence_item"> </dtml-in> </dtml-in>