 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Anthony Ferrara: On Templating
by Chris Cornutt December 11, 2012 @ 11:50:31
In this latest post to his site Anthony Ferrara take a look at templating in web applications - more specifically as it deals with his experience with the Mustache templating engine.
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: Mustache. I've learned a lot while playing with Mustache, and it's really changed my entire viewpoint on presentation layer construction.
He briefly gives an overview of "the past" of templating in PHP (including a mention of Smarty) and how templating tools - like Mustache - 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 Twig templating engine in the comments, another popular option from the Symfony project.
voice your opinion now!
templating presentation mustache twig introduction opinion
Dean Clatworthy: Theming/styling error messages in Symfony 2
by Chris Cornutt August 30, 2012 @ 11:40:40
For the Symfony2 users out there, Dean Clatworthy has a handy tip to help you customize the output of your application a bit more - a method for styling the error messages coming from forms using a custom template.
I spent a large portion of my day today trying to customize the HTML produced by Symfony 2 for form errors. The documentation has a section on how to do this, but for the life of me, I could not make it work. Here is a working, re-usable solution.
His solution involves the creation of a template in your "/Resources/views/Form/" directory that contains a Twig template for the error set output. This is then applied in your view using an additional parameter on the error output tag, including this new template from the "Form" directory. This sort of styling could also be applied if you needed custom elements with their own layouts in your forms as well.
voice your opinion now!
symfony2 error message theme style twig template tutorial
Reddit.com: Symfony2... to Twig or not to Twig...
by Chris Cornutt May 30, 2012 @ 11:32:30
In this recent post on Reddit.com a developer of a Symfony2 application asks, "to Twig or not to Twig for templating in his views.
Hey there... long time Symfony 1.x enthusiast here, finally getting my feed wet with Symfony2. I pose this question to the Symfony2 developers out there: Who's using Twig for templating? Why or why not?
The answers tange from the obvious "yes" and "no" options out to suggestions that even using templating languages are a bad idea. A few point out that the "separation of concerns" as a valid reason while others discount them by dismissing the "designers don't have to learn a language" myth that seems to still be so popular. There's also a few mentions of other templating projects like Smarty and Savant.
voice your opinion now!
twig template opinion symfony2
Project: Gitlist - A Git Repository Viewer (based on Silex & Twig)
by Chris Cornutt May 18, 2012 @ 09:45:46
Klaus Silveira has submitted a project he's been working on to make browsing through git repositories a bit simpler with a local tool - gitlist.
GitList is an elegant and modern web interface for interacting with multiple git repositories. It allows you to browse repositories using your favorite browser, viewing files under different revisions, commit history, diffs. It also generates RSS feeds for each repository, allowing you to stay up-to-date with the latest changes anytime, anywhere. GitList was written in PHP, on top of the Silex microframework and powered by the Twig template engine. This means that GitList is easy to install and easy to customize. Also, the GitList gorgeous interface was made possible due to Bootstrap.
Since it's just a PHP-based application, installing it is as easy as cloning the source to a web-accessible directory and setting up a "config.ini" file with your settings. You can find out more about this project based on the popular Silex microframework on its GitHub page.
voice your opinion now!
silex microframework twig template gitlist repository viewer
Chris Hartjes' Blog: Organzing Slim Framework Applications
by Chris Cornutt February 15, 2012 @ 08:57:28
One of the more popular PHP microframeworks right now is Slim and Chris Hartjes has a new post to his blog about a good way he's found for organizing applications that use this handy tool.
I've never really used a microframework in PHP before. I used Flask for a Python project that I did to experiment with using Google App Engine. The principles seem to be quite similar (although I will admit that having decorators in PHP would be ineresting) but the trade-off with a microframework is that you usually have to figure out an application layout for yourself.
He also uses the Pimple dependency injection container, Twig templating and Composer for package management. He describes how he got it all set up - organizing the code so Composer could understand it, creating the Twig templates directory and creating some of his default routes.
voice your opinion now!
slim application organization composer pimple twig
Derick Rethans' Blog: Twig extension
by Chris Cornutt November 21, 2011 @ 08:35:39
In a new post from Derick Rethans he talks about an extension version of Twig, the popular templating engine from the creators of the Symfony framework.
A while ago, Fabien asked me to have a look at porting one of Twig's slowest methods, TwigTemplate::getAttribute(), into a PHP extension. It is a complex method that does a lot of different checks and look-ups. Fabien's benchmarks showed that this method was responsible for quite a large amount of time. On top of that, it didn't seem that it could be optimised any further as PHP code itself.
He points to the twig-ext extension that's a reworked version of the "getAttribute" method from the tool and the performance gain (about 15%) it gives. Compiled templates will automatically call this new method in the extension. This update has already been merged into the main Twig repo.
voice your opinion now!
twig extension template language symfony speed
Smashing Magazine: Getting Started With PHP Templating
by Chris Cornutt October 18, 2011 @ 09:15:49
On the Smashing Magazine site today there's a new post introducing you to templating in PHP applications. They cover both the creation of a simple, custom templating library as well as using a more widely known too - Twig.
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).
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 Smarty, PHPTAL and Twig, 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.
voice your opinion now!
templating tutorial introduction twig smarty phptal
NetTuts.com: Rapid Application Prototyping in PHP Using a Micro Framework
by Chris Cornutt September 06, 2011 @ 09:56:57
On NetTuts.com today there's a new tutorial posted about using a microframework for prototyping an application you may not need a full stack framework to get running. Their examples are based on the Slim framework.
Let's face it: we all have great ideas for a web application. Whether you write them down on paper or remember them using your eidetic memory, there comes a point when you want test whether or not your idea is really viable. In this tutorial, we'll use a micro framework, a templating language and an ORM to rapidly develop an application prototype.
There's an introduction to help you get Slim, some extras, Twig templating and Paris and Idorm set up and working happily together. There's code included for bootstrapping the application, creating a few routes, building models and using them to pull data from the database. They also create an "admin" area for their sample blog application, building an "add article" form and protecting it with a simple login system. You can download the source if you'd like to see it all working together.
voice your opinion now!
microframework tutorial rapid prototype slim twig paris idiorm
|
Community Events
Don't see your event here? Let us know!
|