Having fun with Twig right now. Here’s a draft View implementation with i18n support. Just a gist, but works very well for me.
For those who don’t know what Twig is:
- Twig is a template language.
- http://www.twig-project.org
The good old default.ctp in Twig
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
{{ html.charset() }}
<title>{{ 'CakePHP: the rapid development php framework'|trans }}: {{ title_for_layout }}</title>
{{ html.meta('icon') }}
{{ html.css('cake.generic') }}
{{ scripts_for_layout }}
</head>
<body>
<div id="container">
<div id="header">
<h1>{{
html.link('CakePHP: the rapid development php framework'|trans, 'http://cakephp.org')
}}</h1>
</div>
<div id="content">
{{ session.flash() }}{{ session.flash('auth') }}
{{ content_for_layout }}
</div>
<div id="footer">
{{
html.image('cake.power.gif', [
'alt': 'Powered by CakePHP'|trans,
'url': 'http://cakephp.org'
])
}}
</div>
</div>
</body>
</html>
Here’s my TwigView class
==UPDATED==
It's a repo now:
> http://github.com/m3nt0r/cakephp-twig-view
There are also more examples and examples using FormHelper at github.
View the full gist: http://gist.github.com/589273
Comments are closed