techwilk / twig-slim-csrf
TWIG extension to expose Slim CSRF values in templates.
Installs: 2 603
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- twig/twig: ~1.27|~2.0
This package is auto-updated.
Last update: 2024-11-20 07:46:25 UTC
README
TWIG extension to expose Slim CSRF values in templates. Initially copied from the example in the Slim CSRF readme to this repo to allow installation through composer, though modifications may have since been made.
Installation
- Install through composer.
composer require techwilk/twig-slim-csrf
- Then pass in an instance of
\Slim\Csrf\Guard
:
$guard = new \Slim\Csrf\Guard(); $slimCsrf = new \TechWilk\Twig\Extension\SlimCsrf($guard); $twig->addExtension($slimCsrf);
Use
Use as a standard twig properties:
<input type="hidden" name="{{csrf.keys.name}}" value="{{csrf.name}}"> <input type="hidden" name="{{csrf.keys.value}}" value="{{csrf.value}}">