8000 [TwigBridge] added a render_* function to ease usage of custom render… · symfony/symfony@a0c49c3 · GitHub
[go: up one dir, main page]

Skip to content

Commit a0c49c3

Browse files
committed
[TwigBridge] added a render_* function to ease usage of custom rendering strategies
Here is the code you need to write when using the regular render function for an ESI strategy: {{ render(path('path'), { strategy: 'esi' }) }} And the same with the new render_* function: {{ render_esi(path('path')) }}
1 parent 9aaceb1 commit a0c49c3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Symfony/Bridge/Twig/Extension/HttpKernelExtension.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function getFunctions()
3737
{
3838
return array(
3939
'render' => new \Twig_Function_Method($this, 'render', array('is_safe' => array('html'))),
40+
'render_*' => new \Twig_Function_Method($this, 'renderStrategy', array('is_safe' => array('html'))),
4041
'controller' => new \Twig_Function_Method($this, 'controller'),
4142
);
4243
}
@@ -56,6 +57,13 @@ public function render($uri, $options = array())
5657
return $this->renderer->render($uri, $options);
5758
}
5859

60+
public function renderStrategy($strategy, $uri, $options = array())
61+
{
62+
$options['strategy'] = $strategy;
63+
64+
return $this->renderer->render($uri, $options);
65+
}
66+
5967
public function controller($controller, $attributes = array(), $query = array())
6068
{
6169
return new ControllerReference($controller, $attributes, $query);

0 commit comments

Comments
 (0)
0