Download the PHP package sunlight-cms/twig-plugin without Composer
On this page you can find all versions of the php package sunlight-cms/twig-plugin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package twig-plugin
Twig plugin ###########
Twig integration plugin.
Requirements
- PHP 7.2.5+
- SunLight CMS 8
Usage
See Twig documentation.
$output = TwigBridge::render('@extend/my-plugin/example.html.twig', [ 'foo' => 'bar', ]);
HCM module
Any extra arguments after template name are available in the args
variable.
[hcm]twig,upload/my_template.html.twig,foo,bar[/hcm]
Namespaces
- default: project root
@extend
: plugins/extend@templates
: plugin/templates
Globals
The sl
global variable is available to all templates.
Proxies allow calling any static method on the target class.
Variable | Description |
sl.debug sl.root sl.url sl.baseUrl sl.urlHelper sl.router sl.hcm sl.extend sl.xsrf sl.user sl.form sl.post sl.generic sl.request | debug mode (true / false ) path to project root directory current URL object base URL object Sunlight\Util\UrlHelper proxy Sunlight\Router proxy Sunlight\Hcm proxy Sunlight\Extend proxy Sunlight\Xsrf proxy Sunlight\User proxy Sunlight\Util\Form proxy Sunlight\Post\PostService proxy Sunlight\GenericTemplates proxy Sunlight\Util\Request proxy |
Functions
lang()
: alias for_lang()
call()
: alias forcall_user_func()
dump([value], [maxLevel], [maxStringLen])
: alias forKuria\Debug\Dumper::dump()
Extend events
twig.init
Called when Twig is being initialized. Can be used by other plugins to register their custom twig functionality.
Arguments:
env
- instance ofTwig\Environment
loader
- instance ofSunlightExtend\Twig\TemplateLoader
Overriding templates
Templates may be overriden by calling $loader->override($name, $newName)
during the twig.init event.
To bypass template overrides (e.g. when extending overriden templates),
prepend !
to the template name. Example: !@extend/my-plugin/example.html.twig
.