Python embedded like PHP

Ian Bicking ianb at colorstudy.com
Tue Mar 19 15:03:46 EST 2002


Andrew McNamara <andrewm at object-craft.com.au> wrote in message news:<mailman.1015988122.18668.python-list at python.org>...
> Albatross encourages (but doesn't enforce) the separation of presentation
> and logic. You might do something like this in Albatross:
> 
>     <ul>
>     <al-for iter="reptile" expr='["Crocodile", "Python", "Iguana", "Tortoise"]'>
>       <li><al-value expr="reptile.value()" whitespace></li>
>     </al-for>
>     </ul>

Why, oh why, does it use HTML-like syntax?  People keep implementing
templating languages that do this over and over, and it's a bad, bad
idea.  Any moderately complex example of templating will violate the
rules of HTML/SGML, with things like <img src="<al-value
expr="something">">, which is horrible to read, will anger WYSIWYG
editors to no end, and isn't at all necessary.

All you have to do is use [] instead of <> -- it look about the same,
will have all the good cognitive associations (how nesting works,
etc), but is orthogonal to HTML, just like your templating system is
orthogonal to HTML.  I.e., you're templates would look like

  <ul>
  [al-for iter="reptile" expr='["Crocodile", "Python"]'] 
    <li>[al-value expr="reptile.value()]</li>
  [/al-for]
  </ul>

This still causes problems with repeating table lines (since they'll
be [al-for...] text between <table> and <tr>), but it will still be
much better.  And it should be trivial to implement :)

  -- Ian Bicking



More information about the Python-list mailing list