Skip to content

CakePhp2 View class that provides work with Twig template engine

Notifications You must be signed in to change notification settings

Dmitry404/CakePhpTwig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 

Repository files navigation

This is development version yet so something may don't work

###CakePhp2 plugin that provides an ability of usage Twig template engine

How to install

  • Clone this repository to your plugins directory
$ cd app/plugins 
$ git clone git://github.com/Dmitry404/CakePhpTwig.git
  • Add to your AppController this property
public $viewClass = 'CakePhpTwig.Twig';
  • Enable plugin into your bootstrap.php file
CakePlugin::load('CakePhpTwig');

Simple example of usage

  • layout (View/Layouts/default.htm)
<html>
<head>
    {{ Html.charset() }}
    <title>{% block title %}{% endblock %}</title>

    {{ Html.css('cake.generic') }}

    {% block scripts %}{% endblock %}
</head>
<body>
    <div id="container">
        <div id="header">
            <h1>Test Page</h1>
        </div>
        <div id="content">
            {% block content %}{% endblock %}
        </div>
        <div id="footer"></div>
    </div>
</body>
</html>
  • any view file (for example View/Pages/index.htm)
{% extends "/View/Layouts/default.htm" %}

{% block scripts %}
  <script>
    console.log('hello console');
  </script>
{% endblock %}

{% block content %}
    <span class="notice">
        Hello World
    </span>
{% endblock %}

About

CakePhp2 View class that provides work with Twig template engine

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages