« Back to blog

Blog: TwigView plugin for CakePHP 2.0

Graham Weldon

06 December, 2011

Twig is a templating engine for PHP, and its kickass. It has a whole heap of awesome features.. and since the website itself does a great job of explaining the features, I won't go into detail about them here.

Last night I took a look at the Twig plugin for CakePHP by m3nt0r which is built for CakePHP 1.x, and has support for CakePHP 2.0. I spent a fair amount of time tweaking, tinkering and moving things around to make it a CakePHP 2.0 only plugin, and refactoring to make things simpler.

You can find the TwigView Plugin for CakePHP that I have created on Github.

Whats different is that all CakePHP 1.x functionality has been removed, class names have been changed to match standards (for the most part) for CakePHP 2.0. Lots of code was removed to keep things simple, and its been tested and is working.

There are a few changes that I want to make moving forward with it. I'll be removing the tpl extension being forced on views, so that developers can drop-in this plugin and start using it without changing their filename strategy. I will also allow this to passthrough the traditional CakePHP view parsing as an option.

Given the functionality of the plugin diverges from the main plugin and breaks backwards compatability, I have not submitted a pull request, and may not at this stage.

I hope the plugin is useful for someone. Let me know if you are using it, or if you have any feedback.

Comments