dev-master
9999999-dev http://github.com/peec/minibase-plugin-twigThis plugins replaces the PHP templating engine with Twig. Great for those who likes twig.
MIT
The Requires
- php >=5.4.0
- minibase/minibase dev-master
- twig/twig 1.*
This plugins replaces the PHP templating engine with Twig. Great for those who likes twig.
Enables Twig based templates. Uses the same interface as Minibase offers for
rendering normal PHP views. Also includes custom blocks, filters and functions to take the full out of Minibase. Easily do Fragment caching
., (*1)
This plugin makes it possible to render .twig
and .html
files with the Twig templating engine. .php
files will still get rendered by the default Minibase view rendering engine., (*2)
{ "require":{ "pkj/minibase-plugin-twig": "dev-master" } }
Setup global view path, we need to know where twig templates are located., (*3)
$mb->setConfig(MB::CFG_VIEWPATH, __DIR__ . '/views');
Init the plugin, (*4)
$mb->initPlugins(array( 'Pkj\Minibase\Plugin\TwigPlugin\TwigPlugin' => array( // Where to store the compiled php templates. 'cache' => __DIR__ . '/template_compilation_cache' ) ));
Start using twig templates., (*5)
Reverse routing is easy., (*6)
Reverse routing: {{"News.show"|route(32)}} Prints forexample: /news/32 {{"News.index"|route()}} Prints forexample: /news
Check if a route is active: {% if "News.index"|route().isActive %} Currently on homepage. {% endif %}
Easily add assets, the assets will have the correct base path included., (*7)
<link rel="stylesheet" type="text/css" href="{{"css/style.css"|asset}}" /> Or from a variable <img src="{{news.img_path|asset}}" />
Easily cache bits of your view, VERY good if you use a ORM that have lazy loading such as Doctrine!, (*8)
{% cache "uniqueKey1" %} Hello I am cached forever! {% endcache %} {% cache "uniqueKey2" 3600 %} I am cached for 1 hour. {% endcache %}
This plugins replaces the PHP templating engine with Twig. Great for those who likes twig.
MIT