Jean-Marc Orliaguet wrote:
Martijn Faassen wrote:

It had unit tests, and the regex stuff that I was referring to may be
interesting - it ports the regexes from Zope's TALES to Javascript so
that the parsing of tales expressions works the same.

This is the module that has the regex bits, ported directly, if I recall correctly, from Zope's python code:

OK I see, it's the variable substitution;

string:${name}/${address} ..

I don't think it has an implementation of string TALES expressions.

It's parsing anything that's actually *inside* the attributes you add on HTML with tal, such as detecting whether a TALES expression type identifier is used ('string:' or 'python:', say), or 'structure', and the right splitting of tal:repeat="foo bar" (into 'foo' and 'bar'), and semicolons for multiple attributes with tal:attributes, and so on. I just literally ported that code to javascript from Zope's implementation so it follows the established rules pretty well.

More in general, it's possible that some template will receive two sets of data that's quite separate from each other. I like namespaces then too. You can of course always argue that such a template should be factored into multiple smaller ones, though the question remains how they'd each receive only their data and not the rest.

what I mean it that the structures can always be merged before they are passed to the template, then the data can be organized as:

data = {
 items: [ ...],
 people: [],
 somemoredata: {}

ZPT does a mapping between several data structures (context, request, view ...) and the variables with the same name in TAL, which results in several namespaces. Such variables are very platform-dependent and a templating language basically needs only one data structure to do the rendering..

I'm not sure I understand fully... Perhaps you mean this:

A pattern in templating is to prepare the data fully in nested dictionaries and lists with simple strings and integers inside before the data is pushed along to a template, as opposed to the template pulling it out of request and context and view individually (with method calls, often). Perhaps you are referring to this pattern. I like this pattern, as it has positive qualities concerning debuggability, modularity, loose coupling and makes possible various performance optimizations.

XSLT and ClearSilver are templating languages which have this pattern. TAL can be made to follow this pattern with some small modifications.


Zope3-dev mailing list

Reply via email to