Justin French wrote:

In the aftermath of the Smarty debate (which turned from intelligent to stupid very quickly), I decided to look closely at templating again (though not smarty), and I've found one are where these excel in comparison to PHP.

Textpattern [1] is a gamma release CMS/blog tool which uses XML templating very effectively -- and I can't see an easy way to reproduce this with straight PHP.

<txp:foo a='cat' b='dog' c='mouse'>something</txt:foo> might translate to the following PHP code:
<?=tag_foo(array('a'=>'cat','b'=>'dog','c'=>'mouse'),'something'); ?> OR
<?=tag_foo('cat','dog','mouse','something'); ?>


Easy enough, except this is where the XHTML wins:
For the PHP versions, the template designer must have an in-depth knowledge of the functions. He/she must get the parameters in the right order, know which ones have default values, etc etc. Making a mistake will generate errors and break code.


The XHTML version on the other hand doesn't ask any more or less of the designer than XHTML does. I can switch the order of the arguments, leave some out, etc etc, leaving the hard work to the PHP function on the other end to sort it all out.


So, my question is:


Am I missing something in regards to PHP's functions that would give us some more simplicity? The closest I can think of is to pass the attributes in any order using 'attr=value', then using funct_get_args() to sort it all out:
<?=tag_foo('b=dog','a=cat','content=something','c=mouse')?>


But this is STILL less intuitive than:
<txp:foo b='dog' a='cat' c='mouse'>something</txt:foo>


Any ideas? John????


---
Justin French
http://indent.com.au

Well....that seems a bit hard to understand to me. Why did you choose not to go with Smarty? Or, say, another templating system?


You could do a few things, depending on how much PHP you want in there. You could use this kind of syntax:
<?tag_foo('b', 'dog', 'a', 'cat')?>
Where the first parameter is the "key" and the next is the value. Or, morre explicitly:
<?tag_foo(array('b' => 'dog', 'a' => 'cat'))?>


Or you could even use XML and use XSL or PHP to convert it yourself.

--
paperCrane <Justin Patrin>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to