credy / yii2-twig-stringrenderer
Twig string renderer for Yii2 Framework
1.0.0
2024-07-11 15:33 UTC
Requires
- yiisoft/yii2: ^2.0
- yiisoft/yii2-twig: ^2.0
Requires (Dev)
- codeception/codeception: ^4.2
- codeception/module-asserts: ^1.0.0
- codeception/module-yii2: ^1.1
This package is auto-updated.
Last update: 2024-10-11 13:08:42 UTC
README
Installation
The preferred way to install this extension is through composer.
Run
composer require --prefer-dist credy/yii2-twig-stringrenderer
Usage
Either use directly in your class:
use credy\twig\StringRenderer;
class YourClassName extends BaseObject
{
public function yourMethod()
{
$renderer = new StringRenderer();
$renderer->render('your twig {{ template_name }}', [
'template_name' => 'template'
]);
}
}
or put following snippet into your config:
return [
'components' => [
'twigRenderer' => [
'class' => credy\twig\StringRenderer::class,
]
]
];
And use the component in your class:
class YourClassName extends BaseObject
{
public function yourMethod()
{
Yii::$app->twigRenderer->render('your twig {{ template_name }}', [
'template_name' => 'template'
]);
}
}