Skip to content

Instantly share code, notes, and snippets.

@serapheem
Created November 6, 2012 10:33
Show Gist options
  • Save serapheem/4023928 to your computer and use it in GitHub Desktop.
Save serapheem/4023928 to your computer and use it in GitHub Desktop.
Symfony2 - Render controller action from template
Twig:
{# app/Resources/views/base.html.twig #}
{# ... #}
<div id="sidebar">
{% render "AcmeArticleBundle:Article:recentArticles" with {'max': 3} %}
</div>
PHP:
<!-- app/Resources/views/base.html.php -->
{# ... #}
<div id="sidebar">
<?php echo $view['actions']->render('AcmeArticleBundle:Article:recentArticles', array('max' => 3)) ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment