[devtalk] Straw poll - templating

David Precious davidp at preshweb.co.uk
Fri Mar 20 10:20:56 GMT 2009


On 03/20/2009 07:26 AM, Matthew Macdonald-Wallace wrote:
 > I'll see if I can adapt it to one of the templating systems, although
> I was hoping to make it even more accessible to people who are not  
> necessarily PHPDev's by not requiring people to learn a complete  
> templating system.  

To be fair, it's pretty damn easy to learn - designers shouldn't have to
know PHP, just a few basic snippets of how to use templating.

For instance:

  <p>Hello there, {$user_name}</p>

That's not too hard, is it? :)

(That template variable would have been previously assigned to the
template by your code, with something like:

  $smarty->assign('user_name', $_SESSION['username']);



It can deal with HTML escaping etc too, so you could use, for instance,

  <p>You entered: {$something|escape}</p>

And any HTML they entered will be escaped for you.

(Which is obviously good practice to prevent XSS attacks.)


You can also use other modifiers, for instance:

  <p>Hello, {$user_name|capitalize}</p>


For a much more detailed overview, see http://www.smarty.net/crashcourse.php

It's really not hard :)


Cheers

Dave P




More information about the devtalk mailing list