[Seaside] sending messages in lists
Avi Bryant
avi@beta4.com
Mon, 3 Jun 2002 17:25:46 -0700 (PDT)
On Mon, 3 Jun 2002, Tim Rowledge wrote:
> > <li sea:id="each/practiceTest">... [remainingTries:] </li>
> What would be wrong with allowing
> <li sea:id="each/practiceTest">... [remainingTries:each] </li>
> or something similar? The parsing only needs to be able to pick up on
> the local var name for this repeat (and any parents I suppose) which
> ought not be much more difficult than all the work it does already,
> surely?
Ah, it's a fine line... what about [remainingTries: each foo]?
[remainingTries: (each foo sortedBy: bar)]? Do you only allow that for []
strings, or do you also allow it for something like
<if sea:id="anyTriesLeft:each">? These aren't rhetorical questions, I
just see danger ahead.
I've even considered going much further down that road by changing the
template parser to output sourcecode instead of an element tree; each
element type would then become a sort of macro, and instead of using
special template locals you'd just use block temps. So a template like
<li sea:id="each/practiceTest">
<a sea:id="chooseTest:each">foo</a>
[remainingTries:each]</li>
would generate something along the lines of
self practiceTest do:
[:each |
stream nextPutAll: '<li>'.
stream nextPutAll: '<a href='.
stream nextPutAll: self urlFor: [self chooseTest: each] fixTemps.
stream nextPutAll: '>foo</a>'.
stream nextPutAll: (self remainingTries: each).
stream nextPutAll: '</li>']
The tricky part would be integrating bindings/handlers with this. That
is, how do you override the defaults? By specifying strings of source
code to be inserted?