Download the PHP package hypejunction/elgg-twig without Composer
On this page you can find all versions of the php package hypejunction/elgg-twig. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hypejunction/elgg-twig
More information about hypejunction/elgg-twig
Files in hypejunction/elgg-twig
Package elgg-twig
Short Description Twig Template Rendering for Elgg
License GPL-2.0
Homepage http://hypejunction.com
Informations about the package elgg-twig
Twig Templates for Elgg
Adds support for twig templates in Elgg
Using Templates
To add a twig template, simply add a file with .twig
extension into your plugin's views, under default
viewtype.
To render a template use `elgg_twig()
with or without a view name without .twig
extension:
You can override templates like any other view, but you can not extend them or filter them using hooks.
Development
To simplify development, set environment
config value to development
, otherwise you need to flush caches to reload template changes.
Globals
Globals available in templates
app
- application dataapp.user
- logged in user entityapp.site
- site entityapp.registrationUrl
- registration URLapp.loginUrl
- login URL
Functions
Function available in templates
echo()
- equivalent ofelgg_echo()
view()
- equivalent ofelgg_view()
assetUrl()
- equivalent ofelgg_get_simplecache_url()
requireJs()
- equivalent ofelgg_require_js()
Notes
I have initially taught elgg_view()
to render twig templates, but it had a negative
performance impact, likely because of a view_vars
hook registered for all views.
Until there is a wildcard hook registration, elgg_twig()
is the way to go,
however it does not allow view vars to be filtered or views to be extended, which in the end
is somewhat a win, because of simplicity.
All versions of elgg-twig with dependencies
composer/installers Version ~1.0
twig/twig Version ^2.6
hypejunction/elgg-di Version *