<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Wed, 19 Jun 2013 12:47:45 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Anthony Ferrara: On Templating]]></title>
      <guid>http://www.phpdeveloper.org/news/18874</guid>
      <link>http://www.phpdeveloper.org/news/18874</link>
      <description><![CDATA[<p>
In <a href="http://blog.ircmaxell.com/2012/12/on-templating.html">this latest post</a> to his site <i>Anthony Ferrara</i> take a look at templating in web applications - more specifically as it deals with his experience with the <a href="http://mustache.github.com/">Mustache</a> templating engine.
</p>
<blockquote>
I've been playing around with tempting engines a lot lately. For a recent project, I needed the ability to re-use the same template set in both JS and PHP (coupled with the History API, providing seamless dynamic behavior, yet still having raw content pages). Realistically today, there's only one choice for that sort of requirement: <a href="http://mustache.github.com/">Mustache</a>. I've learned a lot while playing with Mustache, and it's really changed my entire viewpoint on presentation layer construction.
</blockquote>
<p>
He briefly gives an overview of "the past" of templating in PHP (including a mention of <a href="http://www.smarty.net/">Smarty</a>) and how templating tools - like <a href="http://mustache.github.com/">Mustache</a> - have helped to improve the situation, especially when it comes to the separation of presentation and processing. As an alternative, there's also a mention of the <a href="http://twig.sensiolabs.org/">Twig</a> templating engine in the comments, another popular option from the Symfony project.
</p>]]></description>
      <pubDate>Tue, 11 Dec 2012 11:50:31 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Sean Coates' Blog: PHP as a templating language]]></title>
      <guid>http://www.phpdeveloper.org/news/17960</guid>
      <link>http://www.phpdeveloper.org/news/17960</link>
      <description><![CDATA[<p>
In <a href="http://seancoates.com/blogs/php-as-a-templating-language">this new post</a> to his blog <i>Sean Coates</i> talks about PHP as a templating language and why he (and <a href="http://gimmebar.com">Gimmebar</a>) have decided to go another, more frontend-based direction.
</p>
<blockquote>
For many years, I was a supporter of using PHP as a templating language to render HTML. However, I really don't buy into the idea of adding an additional abstraction layer on top of PHP, such as <a href="http://smarty.php.net/">Smarty</a> (and many others). In the past year or so, I've come to the realization that even PHP itself is no longer ideally suited to function as the templating engine of current web applications - at least not as the primary templating engine for such apps.
</blockquote>
<p>
His reasoning is pretty simple - more and more web applications are becoming less and less server-driven. When building applications (and APIs) you don't know how the data will be consumed, so your frontend has to be agnostic. So, what's his current alternative of choice? The <a href="http://mustache.github.com/">Mustache</a> templating framework provides a simple way to create reusable templates (along with the compatible <a href="http://handlebarsjs.com/">Handlebars</a> Javascript library).
</p>]]></description>
      <pubDate>Tue, 15 May 2012 10:58:37 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[WorkingSoftware Blog: Your templating engine sucks & everything you've written is spaghetti code]]></title>
      <guid>http://www.phpdeveloper.org/news/17259</guid>
      <link>http://www.phpdeveloper.org/news/17259</link>
      <description><![CDATA[<p>
In a bit of a ranting post on the WorkingSoftware.com.au blog <i>Iain Dooley</i> shares his opinion about most of the code he's seen, specifically related to templating engines: "Your templating engine sucks and everything you have ever written is spaghetti code (yes, you)".
</p>
<blockquote>
Templating is a real hot button in the web development community. [...] The high horses that people usually get on are that all too familiar TLA MVC (Model/View/Controller) architecture and "separation of presentation and business logic". The poor pedestrians upon which they look down are those who have written "spaghetti code" - templates where presentation logic, markup, business logic, database access configuration and whatever else you might imagine are mixed up in the same file. Well, I've got some news for you: you're all wrong.
</blockquote>
<p>
He points out that, with most of the major templating tools out there, there's most people still put some sort of business logic in their templates. Rarely will you find a "pure" template that only echoes out the data. He gives an example of a <a href="http://mustache.github.com">Mustache</a> template with "empty" logic in it. He shares a new term his coined too: "Template Animation". This is the separation of the templating process as it is usually done and splitting it so that the output is a modified DOM resource rather than a static template. 
</p>
<p>
He talks about some of the advantages of this approach and an example of its use in an example of a logged in user vs not logged in user as well as a brief discussion of Markdown/HAML.
</p>
<blockquote>
The only thing that Template Animation advocates is that the technological barrier between the frontend and the backend is never crossed - that our templates are truly logic-less.
</blockquote>
<p>
There's <a href="http://www.workingsoftware.com.au/page/Your_templating_engine_sucks_and_everything_you_have_ever_written_is_spaghetti_code_yes_you">lots of comments on the post</a> already - everything from support of the idea to systems that already implement this sort of idea to disagreeing opinions.
</p>]]></description>
      <pubDate>Wed, 14 Dec 2011 12:03:54 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Smashing Magazine: Getting Started With PHP Templating]]></title>
      <guid>http://www.phpdeveloper.org/news/17005</guid>
      <link>http://www.phpdeveloper.org/news/17005</link>
      <description><![CDATA[<p>
On the Smashing Magazine site today there's a new post <a href="http://coding.smashingmagazine.com/2011/10/17/getting-started-with-php-templating/">introducing you to templating</a> in PHP applications. They cover both the creation of a simple, custom templating library as well as using a more widely known too - <a href="http://twig-project.org">Twig</a>.
</p>
<blockquote>
In this article, we'll cover how to separate the view of your PHP application from its other components. We'll look at why using such an architecture is useful and what tools we can use to accomplish this. [...] To fully benefit from this article, you should already know how to write and run your own PHP scripts on a Web server (i.e. using Apache).
</blockquote>
<p>
They start with the very basics of templating, mostly pointing out how it reduces the dependency of having layout code directly in your application's logic. It makes things easier to reuse and makes for better code structure in the long run. They mention other templating engines like <a href="http://www.smarty.net/">Smarty</a>, <a href="http://phptal.org/">PHPTAL</a> and <a href="http://www.twig-project.org/">Twig</a>, but focus in on the last for their code samples. They show basic templating, making reusable templates, applying filters and working with simple control structures.
</p>]]></description>
      <pubDate>Tue, 18 Oct 2011 09:15:49 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Ryan Mauger's Blog: Using Twig with Zend Framework]]></title>
      <guid>http://www.phpdeveloper.org/news/16297</guid>
      <link>http://www.phpdeveloper.org/news/16297</link>
      <description><![CDATA[<p>
<i>Ryan Mauger</i> has written up a new post about an integration he's done using the <a href="http://twig-project.com">Twig</a> templating engine (from be Symfony community) with his Zend Framework application to <a href="http://www.rmauger.co.uk/2011/05/using-twig-with-zend-framework/">make view handling simpler</a>.
</p>
<blockquote>
Mostly I thought [what Twig offered] were silly things that were not really needed unless you had a team of designers to work with, however, during my exploration, a couple of things occurred to me that I had not considered about templating systems before. One being the enforced separation of concerns they provide; you simply cannot do anything from inside them which you shouldn't be, keeping your presentation very very clean. The second, being that they're not all as terrible as Smarty.
</blockquote>
<p>
He helps you get Twig installed (via PEAR chnnel) and includes the code for an application resource and the changes you'll need to make to your application.ini to get things working. He uses a base controller setup, so he shows how to introduce a "twig()" method into that to help with rendering. Finally, there's a sample class included that includes two actions, both using this "twig()" method to pas the output data through the twig interpreter and out to the view.
</p>]]></description>
      <pubDate>Thu, 05 May 2011 08:28:18 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Zend Developer Zone: Creating Web Page Templates with PHP and Twig (part 1)]]></title>
      <guid>http://www.phpdeveloper.org/news/16162</guid>
      <link>http://www.phpdeveloper.org/news/16162</link>
      <description><![CDATA[<p>
On the Zend Developer Zone today there's a new tutorial from <i>Vikram Vaswani</i> about <a href="http://devzone.zend.com/article/13633-Creating-Web-Page-Templates-with-PHP-and-Twig-part-1">using the Twig templating engine</a> in your application. It's part one of a series that introduces the library to you and includes examples of some of the most common templating logic.
</p>
<blockquote>
Most PHP frameworks, including Zend Framework, Agavi, CakePHP and CodeIgniter, come with built-in templating to enable this separation. However, if you're not a big fan of frameworks, or if your project is small enough that you don't need the additional overhead, you can also consider using a standalone template engine to obtain the same benefits. A number of such engines exist - you've probably already heard of Smarty, Savant, Dwoo and others - and in this article, I'll introduce you to one I discovered rather recently, called Twig.
</blockquote>
<p>
The <a href="http://twig-project.org">Twig</a> project gives you a framework-independent tool for creating simple (or complex, if you'd like) templates for the output of your site. He shows you how to get it installed (via PEAR) and provides some sample templates for things like:
</p>
<ul>
<li>using conditionals (if/else/etc)
<li>looping
<li>working with arrays from PHP
<li>including other templates
<li>using included filtering on data
</ul>]]></description>
      <pubDate>Thu, 07 Apr 2011 12:44:43 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Community News: Has Smarty's Time Come?]]></title>
      <guid>http://www.phpdeveloper.org/news/9407</guid>
      <link>http://www.phpdeveloper.org/news/9407</link>
      <description><![CDATA[<p>
As <i>Paul Jones</i> <a href="http://paul-m-jones.com/?p=273">mentions</a>, there's a sort of force in the PHP community that seems to be pushing back at the <a href="http://smarty.php.net">Smarty templating system</a> and calling it unnecessary. 
</p>
<p>
He points out <a href="http://hasin.wordpress.com/2008/01/05/once-upon-a-time-there-was-smarty/">Hasin Hayder's post</a> on the subject. <i>Hasin</i> (ironically author of a Smarty book) has recently come to the conclusion that there "is no need to use an external template engine like smarty".
</p>
<blockquote>
Some nice guys over there developed smarty and it saved life of a lot of developers (i mean developers). But that time is over. Seriously why the hell I need to learn a new templating language when a "echo" does the thing much better.
</blockquote>
<p>
Judging by the responses to both <a href="http://hasin.wordpress.com/2008/01/05/once-upon-a-time-there-was-smarty/">Hasin's post</a> and <a href="http://paul-m-jones.com/?p=273">Paul's post</a> it seems like quite a bit of the PHP community agrees (including <a href="http://fosterburgess.com/kimsal/?p=406">Michael Kimsal</a>, <a href="http://www.phppatterns.com/index.php/article/articleview/4/1/1/">Harry Fuecks</a> and <a href="http://www.massassi.com/php/articles/template_engines/">Brian Lozier</a>). 
</p>]]></description>
      <pubDate>Fri, 11 Jan 2008 12:53:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Rob Peck's Blog: PHP Templating Celebrity Deathmatch!]]></title>
      <guid>http://www.phpdeveloper.org/news/8453</guid>
      <link>http://www.phpdeveloper.org/news/8453</link>
      <description><![CDATA[<p>
The Code Lemur blog (as penned by <i>Rob Peck</i>) has a <a href="http://codelemur.wordpress.com/2007/08/10/php-templating-celebrity-deathmatch/">new post</a> - a "deathmatch" for two of the PHP-associated templating solutions out there in a fight to the finish - <a href="http://smarty.php.net">Smarty</a> and <a href="http://alexeyrybak.com/blitz/blitz_en.html">Blitz</a>.
</p>
<blockquote>
In this test, I am going to be comparing Smarty (the most widely used PHP templating engine and an official PHP project), Blitz (a new templating engine currently under very active development that is native compiled as a PHP extension), and standard PHP includes.
</blockquote>
<p>
He <a href="http://codelemur.wordpress.com/2007/08/10/php-templating-celebrity-deathmatch/">compares them</a> on three different levels - instantiation, simple template rendering, and complex testing. Each time, there's a victor but in the end, there's really only one "winner" - the PHP language itself that does a great job of templating things easily without the overhead of adding in external libraries.
</p>]]></description>
      <pubDate>Tue, 14 Aug 2007 15:37:50 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPBuilder.com: Smarty Templating System]]></title>
      <guid>http://www.phpdeveloper.org/news/7627</guid>
      <link>http://www.phpdeveloper.org/news/7627</link>
      <description><![CDATA[<p>
PHPBuilder.com has a <a href="http://www.phpbuilder.com/columns/ben_robinson20070413.php3">new article</a> today that takes a look at one of the most popular PHP-based templating systems on the web today - <a href="http://smarty.php.net/">Smarty</a>.
</p>
<blockquote>
The Smarty templating system is a fantastic framework for architecting php-based websites, especially in a collaborative development environment. This article will examine the benefits of Smarty, as well as delve into some basic examples of its implementation. We will also point the way to the available resources and community based around the system.
</blockquote>
<p>
The article is broken up:
<ul>
<li>Why smarty? (making a case - 6 reasons)
<li>Setting it up
<li>Some sample code
<li>and a sample template
</ul>
Simplicity like that is one of the reasons this templating system is so popular. Of course, <a href="http://www.phpbuilder.com/columns/ben_robinson20070413.php3">this is just the tip of the iceberg</a> - there's so much more that it has to offer. Check out <a href="http://smarty.php.net">smaty.php.net</a>.
</p>]]></description>
      <pubDate>Mon, 16 Apr 2007 08:44:00 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Felix Geisendorfer's Blog: Basic CakePHP templating skills]]></title>
      <guid>http://www.phpdeveloper.org/news/6486</guid>
      <link>http://www.phpdeveloper.org/news/6486</link>
      <description><![CDATA[<p>
From the ThinkingPHP blog today, <i>Felix Geisendorfer</i> <a href="http://www.thinkingphp.org/2006/10/11/basic-cakephp-templating-skills/">has shared</a> some of his experience to help those CakePHP users out there that are looking at doing more templating to their applications than just the normal index changes.
</p>
<blockquote>
One of the things I don't see getting to much coverage is how to create good templates when working with CakePHP. Since those are written in plain PHP, this does not apply to CakePHP only. So I'm sure many people have already developed their own style that they are comfortable with and I don't ask for them to change it. However, maybe some people new to the framework / language can benifit by taking a look at the one I'm using.
</blockquote>
<p>
He <a href="http://www.thinkingphp.org/2006/10/11/basic-cakephp-templating-skills/">covers</a> a few different topics: 
<ul>PHP tags
<li>Conditions
<li>Loops
<li>the linebreak issue
<li>avoiding multi-line statements
<li>Creating Zebra striped table rows
</ul>
The code included on some of the points (not the multi-line or the PHP tags items) is simple and is summed up in less than six lines.
</p>]]></description>
      <pubDate>Thu, 12 Oct 2006 07:44:00 -0500</pubDate>
    </item>
  </channel>
</rss>
