Skip to content
Snippets Groups Projects
Commit e253d54a authored by Guy Halse's avatar Guy Halse
Browse files

Document the new Twig templating system

Add some basic documentation on how the new Twig templating system works.
parent 612bbef2
No related branches found
No related tags found
No related merge requests found
...@@ -114,3 +114,20 @@ Example for a custom CSS stylesheet file: ...@@ -114,3 +114,20 @@ Example for a custom CSS stylesheet file:
```html ```html
<link rel="stylesheet" type="text/css" href="<?php echo SimpleSAML_Module::getModuleURL('mymodule/style.css'); ?>" /> <link rel="stylesheet" type="text/css" href="<?php echo SimpleSAML_Module::getModuleURL('mymodule/style.css'); ?>" />
``` ```
Migrating to Twig templates
---------------------------
In version 1.15, a new templating system based on [Twig](https://twig.symfony.com/) was introduced. As modules migrate, it will become necessary for themes to include both the old templating style described above and new Twig-based templates.
Twig works by extending a base template, which can itself include other partial templates. Some of the content of the old `includes/header.php` template is now located in a separate `_header.twig` file. This can be customized by copying it from the base template:
cp templates/_header.twig modules/mymodule/themes/fancytheme/default/
If you need to make more extensive customizations to the base template, you should copy it from the base theme:
cp templates/base.twig modules/mymodule/themes/fancytheme/default/
Any references to `$this->data['baseurlpath']` in old-style templates can be replaced with `{{baseurlpath}}` in Twig templates. Likewise, references to `SimpleSAML_Module::getModuleURL()` can be replaced with `{{baseurlpath}}module.php/mymodule/...`
See the [Twig documentation](https://twig.symfony.com/doc/1.x/templates.html) for more information on using variables and expressions in Twig templates.
...@@ -5,7 +5,9 @@ The minimum required PHP version is now 5.4. The dependency on mcrypt has been ...@@ -5,7 +5,9 @@ The minimum required PHP version is now 5.4. The dependency on mcrypt has been
dropped. dropped.
A new templating system based on Twig has been introduced. The old templating A new templating system based on Twig has been introduced. The old templating
system is still available but should be considered deprecated. system is still available but should be considered deprecated. Custom themes
may need to be updated to include Twig-style templates as well. See the
[theming documentation](simplesamlphp-theming).
A new internationalization system based on Gettext has been introduced. While A new internationalization system based on Gettext has been introduced. While
old templates can use either the old or the new system (refer to the old templates can use either the old or the new system (refer to the
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment