mirror of
https://github.com/slawkens/myaac.git
synced 2026-02-03 11:56:22 +01:00
Twig: Extract renderInline(content, context) as method to $twig
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace MyAAC\Twig;
|
||||
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\ArrayLoader as Twig_ArrayLoader;
|
||||
|
||||
class EnvironmentBridge extends Environment
|
||||
{
|
||||
@@ -25,4 +26,21 @@ class EnvironmentBridge extends Environment
|
||||
|
||||
return parent::render($name, $context);
|
||||
}
|
||||
|
||||
public function renderInline($content, array $context = []): string
|
||||
{
|
||||
$oldLoader = $this->getLoader();
|
||||
|
||||
$twig_loader_array = new Twig_ArrayLoader(array(
|
||||
'content.html' => $content
|
||||
));
|
||||
|
||||
$this->setLoader($twig_loader_array);
|
||||
|
||||
$ret = $this->render('content.html', $context);
|
||||
|
||||
$this->setLoader($oldLoader);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user