Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
TwigView for CakePHP
{{ html.charset() }}
<title>{{ 'CakePHP: the rapid development php framework'|trans }}: {{ title_for_layout }}</title>
{{ html.meta('icon') }}
{{ html.css('cake.generic') }}
{{ scripts_for_layout }}
<div id="container">
<div id="header">
<h1>{{'CakePHP: the rapid development php framework'|trans, '')
<div id="content">
{{ session.flash() }}{{ session.flash('auth') }}
{{ content_for_layout }}
<div id="footer">
html.image('cake.power.gif', [
'alt': 'Powered by CakePHP'|trans,
'url': ''
<h2>Just some Twig template</h2>
<p>{{'text', '#something') }}</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.</p>
{{ form.create('Account') }}
{{ form.input('email') }}
{{ form.input('username') }}
form.input('password', [
'label':'Please enter your password'
form.input('option_test', [
'red': 'Red Option',
'blue': 'Blue Option',
'green': 'Green Option'
{{ form.end('Login') }}
* Converted to plugin repo
* @see
<h2>Elements with Twig</h2>
<p>Twig has it's very own "include" command. You can still use it, but it requires a full path relative to APP/views.</p>
<p>To make transition easier i've added a "element" command that looks in APP/views/elements and does not require the .tpl extension"</p>
<div id="something">
{{ element "my_element" }}
<p>The 'div#something' now has the contents of APP/views/elements/my_element.tpl</p>
{{ form.create('Account') }}
form.input('username', [
'label':'Your Username'|trans
form.input('password', [
'label':'Your Password'|trans
form.input('rememberMe', [
'label':'Remember for 2 weeks'|trans,
{{ form.end('Log in now'|trans) }}
<p>Of course the trans block does work aswell. Just like the filter it pipes the contents to the CakePHP i18n functions "__()"</p>
{% trans %}
Hello {{ username }}!
This is a long translation block.
{% endtrans %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment