Created
November 6, 2012 10:32
-
-
Save serapheem/4023925 to your computer and use it in GitHub Desktop.
Symfony2 - Include template inside another template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Twig: | |
{# src/Acme/ArticleBundle/Resources/Article/list.html.twig #} | |
{% extends 'AcmeArticleBundle::layout.html.twig' %} | |
{% block body %} | |
<h1>Recent Articles<h1> | |
{% for article in articles %} | |
{% include 'AcmeArticleBundle:Article:articleDetails.html.twig' with {'article': article} %} | |
{% endfor %} | |
{% endblock %} | |
PHP: | |
<!-- src/Acme/ArticleBundle/Resources/Article/list.html.php --> | |
<?php $view->extend('AcmeArticleBundle::layout.html.php') ?> | |
<?php $view['slots']->start('body') ?> | |
<h1>Recent Articles</h1> | |
<?php foreach ($articles as $article): ?> | |
<?php echo $view->render('AcmeArticleBundle:Article:articleDetails.html.php', array('article' => $article)) ?> | |
<?php endforeach; ?> | |
<?php $view['slots']->stop() ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment