Re: [Zope-dev] Re: [ZPT] Order of attribute execution Feature Request
HI Jim It's a good point you raise. I personally don't consider tal: and metal: tags to really be a traditional programming language, more a way of including directives and/or python into an XML/html namespace. I think it would depend if you consider each tal: statement in a tag to be all part of a single statement. I view it as being a number of seperate attributes in a xml/html tag, and attributes within a tag are typically order independant. ie <img src="file.gif" border="0" vspace="1" hspace="1"> or <img border="0" vspace="1" hspace="1" src="file.gif"> render exactly the same thing. In addition event handlers in html ie onClick onBlur etc are all order independant. now adding tal: attributes that where order dependant would seem to fly in the face of that convention. (Admittedely there are probably no strange dependancies that could be introduced with different orders of border, src etc) It would also be potentially dangerous have specific authored ordering when non programmers start editing page templates, and accidentally change the order of tags because they looked nice in a different order, or when someone uses a graphical html editor, I have seen ones, where you are given a nice dialog box to edit attributes of a tag, and when it write the values back it always writes them in "it's internally specified order" not the order you specify. This I would imagine could introduce all sorts of nasty bugs. On the basis of in place ordering would it also mean that a attribute should be declared before a tal:attributes could be used. Within an attribute ie tal:define the statements are executed in the order they are specified, which does make sense. I suppose I have put forward more than 2c now ;-) T On Fri, 2002-05-10 at 09:30, Jim Penny wrote:
On Fri, May 10, 2002 at 09:07:26AM +0800, Tim Hoffman wrote:
Hi
Just my 2c worth, but I would like to defend order of execution of ZPT. What it does mean for me is I can guaruntee zpt commands will "always" be processed in a known order irrespective of where you put them in a tag, this I like ;-)
Would you defend a python interpreter that always moved definitions ahead of conditionals ahead of loops?
Does even a "intentionally limited templating language" have the right to second-guess the programmer and re-arrange the order of written commands?
Yes, I am aware that 'C' and fortran and many other languages may do rearrangement of arithmetic expression, and that this may be side-effectful. But, can you point me to any other language that reorders looping and conditionals?
Jim
What I do miss is "else" clause but I think it would be probably be too hard to implement, and too much of encouragement for people to start putting more logic in the template, so on the whole it is probably best to leave it out.
See ya
I feel compelled to take the XML hard line, and point out that depending on the ordering of XML attributes is not compliant: http://www.w3.org/TR/xml-infoset/ XML Information Set W3C Recommendation 24 October 2001 2. Information Items 2.2. Element Information Items An element information item has the following properties: 5. [attributes] An unordered set of attribute information items, one for each of the attributes (specified or defaulted from the DTD) of this element. Namespace declarations do not appear in this set. If the element has no attributes, this set has no members. If you're going to use XML, then use XML, and don't break the spec. The worse thing you could do is to use something-that-almost-looks-like-xml-but-is-slightly-different. That's asking for trouble, and guarantees there will be problems down the line. The whole point of using XML is so people can have the valid expectation that their XML data will work with any compliant XML tool. As somebody else pointed out, many XML editors reorder the attributes (which they are 100% justified in doing), and that is as much a fact of life as what they do with the newlines and white space. If you're going to define a language that's not XML because it depends on attribute ordering, then please use an obviously different syntax (like parenthesis instead of angled brackets), so as not to mislead and confuse people, or corrupt data. If you just want to attach ordered items to an XML element, then use sub-elements which can be ordered, not attributes which are by definition unordered. -Don
Tim Hoffman wrote:
In addition event handlers in html ie onClick onBlur etc are all order independant.
now adding tal: attributes that where order dependant would seem to fly in the face of that convention. (Admittedely there are probably no strange dependancies that could be introduced with different orders of border, src etc)
Indeed. It isn't just a convention. The order of attributes within an XML or SGML tag is explicitly defined not to matter. Two important properties of attributes within a tag are that they are unordered, and they are unique. http://aspn.activestate.com/ASPN/Mail/Message/xml-dev/666339 -- Steve Alexander
participants (4)
-
Chris Withers -
Don Hopkins -
Steve Alexander -
Tim Hoffman