"Rowan Collins" wrote in message news:56efe897.3070...@gmail.com...
Daniel Beardsley wrote on 21/03/2016 06:35:
You are right. Though not all those problems are serious:
* URI escaping:
Does anyone really use <?= ?> or echo when generating a uri?
* Javascript:
Good point, though I would say it's fairly rare to create javascript
code using a php template with variables. The most we ever do
in our app is <?= json_encode($someArray) ?>
I've done both of these in the past (using Smarty, in my case); here's some
example uses:
<a href="/products/<?= $product['category'] ?>/<?= $product['id'] ?>"><?=
$product['name'] ?></a>
<script>var debug_session_id = '<?= get_debug_session_id() ?>';</script>
Now, I'm not saying there aren't better ways of doing these things, but
people absolutely do it like this, and a hook into something as fundamental
as "echo" can't really rely on "it's quite rare" as an excuse for not
accounting for them.
Regards,
I think the whole idea of trying to execute some application logic after the
data has been sent to the templating engine is wrong. I don't use Smarty but
I do use XSLT as my templating engine. This means that I have to copy all
the relevant data to an XML document before I perform the XSL
transformation. There is no need for any application code to be executed in
the transformation process simply because I executed that code BEFORE it was
copied to the XML document.
You should try executing your application logic BEFORE you send your data to
Smarty, then you won't have to bend the templating system to do something it
was not designed to do.
--
Tony Marston
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php