Skip to content

Instantly share code, notes, and snippets.

@Rayne
Created November 28, 2015 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rayne/71bae67f0e1d804d1ed3 to your computer and use it in GitHub Desktop.
Save Rayne/71bae67f0e1d804d1ed3 to your computer and use it in GitHub Desktop.
Fat-Free Framework: Templating with objects and the `Template` class
<repeat group="{{ @articles }}" value="{{ @article }}">
<h1>{{ @article->title }}</h1>
</repeat>
<?php
/**
* @see https://github.com/bcosca/fatfree/issues/891
*/
$f3->route('GET /articles', function(Base $f3) {
$articles = [];
$article = new \stdClass;
$article->title = 'A';
$articles[] = $article;
$article = new \stdClass;
$article->title = 'B';
$articles[] = $article;
echo Template::instance()->render('articles.html', null, ['articles' => $articles]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment