shapecode / twig-string-loader
A string loader for twig
Fund package maintenance!
nicklog
Liberapay
paypal.me/nloges
Installs: 62 345
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: ^7.4|^8.0
- twig/twig: ^2.11|^3.0
Requires (Dev)
- doctrine/coding-standard: ^9.0
- maglnet/composer-require-checker: ^2.0|^3.8|^4.0
- phpstan/phpstan: ^1.4
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpstan/phpstan-strict-rules: ^1.1
- phpunit/phpunit: ^9.5
- roave/security-advisories: dev-master
- squizlabs/php_codesniffer: ^3.4
This package is auto-updated.
Last update: 2023-09-15 16:06:05 UTC
README
Install instructions
First you need to add shapecode/twig-string-loader
to composer.json
:
Do it by execute composer require shapecode/twig-string-loader
or do it manually
{ "require": { "shapecode/twig-string-loader": "^1.0" } }
Add the string loader to your $twig
object
<?php // index.php //... $loader1 = new \Twig\Loader\FilesystemLoader('/path/to/templates'); $loader2 = new \Shapecode\Twig\Loader\StringLoader(); $loader = new \Twig\Loader\ChainLoader([$loader1, $loader2]); $twig = new \Twig\Environment($loader);
Usage
Now you can compile strings with twig:
<?php $twig->render('Hello {{ world }}', array( 'world' => 'World' ));