- Adds support for Twig templates to Kirby CMS (2.3+).
- PHP templates still work, you don’t have to rewrite them if you don’t want to.
Before:
<?php /* site/templates/hello.php */ ?>
<h1><?php echo $page->title() ?></h1>
<?php echo $page->text()->markdown() ?>
After:
{# site/templates/hello.twig #}
<h1>{{ page.title }}</h1>
{{ page.text.markdown | raw }}
If you’re using Kirby’s CLI, you can install with:
kirby plugin:install fvsch/kirby-twig
For manual installation:
- Download the latest release and put it in your
site/plugins
folder. - Rename the copied folder to
twig
(it should be namedsite/plugins/twig
). - To activate the plugin, put
c::set('twig', true);
in yoursite/config/config.php
.
You can now create .twig
templates in your site/templates
directory.
- Twig templating guide
- Complete options documentation
- How errors are displayed (or not)
- Using your own functions in templates
- Twig support in Kirby plugins
- This script: MIT License
- Twig library by Fabien Potencier and contributors / New BSD License (lib/Twig/LICENSE)