[eluser]broofa[/eluser]
First, thanks for making a clean and compact template library. It's been a pleasure to use. However, I've run into a use case that's giving me some problems, and I'd appreciate some advice on how best to solve it. Basically, I'd like to include a subview from within another view, kind of like how Rails' "partials" work.
Here's the specific use case: The app I'm writing is essentially a blog app, where users can create entries and leave comments. There are several views in the app where I'd like to be able to render comments (blog entry, user profile, main home page, etc.). Thus, I'd like to have a single snippet of markup for a "comment list" that is defined in a "comment_list.php" file (greatly simplified here):
Code:
<ul class="comments">
<? foreach ($comments as $comment) {
<li class="comment"><?= $comment->body ?></li>
<? } ?>
</ul>
Then from within the different views, I'd like to include that file by doing something like this:
Code:
<p>blah blah content goes here blah blah </p>
<?
$this->template->include('_comment_list', array('comments' => $user->comments));
?>
<p>blah blah more content goes here blah blah </p>
Is this possible with Template? If so, how?