Skip to content

Commit

Permalink
Add more Twig tests using twig functions and ThemosisTwig extension.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlambe committed May 13, 2016
1 parent aaa948f commit bf81db2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
8 changes: 6 additions & 2 deletions resources/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
*
*/

Route::match(['get', 'post'], 'home', function () {
Route::match(['get', 'post'], 'home', function ($post, $query) {

return View::make('pages.index', ['name' => 'Julien']);
return view('pages.index', ['posts' => $query->get_posts()]);

});

Route::any('404', function () {
return 'Nothing yet';
});
1 change: 1 addition & 0 deletions resources/views/layouts/main.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
&copy; Copyright 2011 by <a href="http://domain.invalid/">you</a>.
{% endblock %}
</div>
{{ wp_footer() }}
</body>
</html>
14 changes: 10 additions & 4 deletions resources/views/pages/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@

{% block title %}Index from Pages directory{% endblock %}
{% block head %}
{{ parent() }}
<style type="text/css">
.important { color: #336699; }
</style>
{{ wp_head() }}
{% endblock %}
{% block content %}
<h1>Page Index</h1>
<p class="important">
Welcome to my awesome homepage.
{{ __('Title', constant('THEME_TEXTDOMAIN')) }}
{{ _e('Post') }}
</p>
<p>{{ fn('bloginfo', 'name') }}</p>
<p>{{ fn.bloginfo('name') }}</p>
{% for post in posts %}
{% set id = post.ID %}
<h2>{{ post.post_title }}</h2>
<a href="{{ fn('get_permalink', id) }}">Read more</a>
{% endfor %}
{% endblock %}

0 comments on commit bf81db2

Please sign in to comment.