Skip to content

Commit

Permalink
Updating starter theme w foo/bar example
Browse files Browse the repository at this point in the history
  • Loading branch information
jarednova committed Oct 9, 2013
1 parent 34a3b67 commit bd096af
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
9 changes: 9 additions & 0 deletions functions/functions-twig.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ function add_twig_filters($twig) {
}
return new TimberImage($pid);
}));
$twig->addFunction(new Twig_SimpleFunction('TimberTerm', function($pid){
if (is_array($pid)){
foreach($pid as &$p){
$p = new TimberTerm($p);
}
return $pid;
}
return new TimberTerm($pid);
}));

/* bloginfo and translate */
$twig->addFunction('bloginfo', new Twig_SimpleFunction('bloginfo', function($show = '', $filter = 'raw'){
Expand Down
11 changes: 10 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Contributors: jarednova
Tags: template engine, templates, twig
Requires at least: 3.5
Stable tag: 0.13.5
Stable tag: 0.14.0
Tested up to: 3.6.1
PHP version: 5.3.0 or greater
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -37,6 +38,14 @@ Timber is great for any WordPress developer who cares about writing good, mainta

== Changelog ==

= 0.14.0 =
* More flexiblity for custom routes (thanks @mgmartel)
* Added filters for core objects (TimberPost and TimberTerm). This greatly helps when you need to have retrived custom fields or repeaters interprted as posts or terms
* Renamed "WPHelper" to more namespace-friendly "TimberHelper"
* Added function_wrapper helper to execute functions where they are placed in the template as opposed to when they are generated (@mgmartel)
* You can now have custom fields processed via post.get_field('my_custom_field'). This is a huge help for using things like Advanced Custom Fields' repeater.
* Performance improvements

= 0.13.5 =
* Added comprehensive support for actions and filters (thanks @mgmartel)
* Rewrote routing to template to be 100% harmonious with WordPress (thanks again @mgmartel)
Expand Down
3 changes: 2 additions & 1 deletion timber-starter-theme/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file
* E.g., it puts together the home page when no home.php file
*
* Methods for TimberHelper can be found in the /functions sub-directory
*
Expand All @@ -21,6 +21,7 @@
$data['menu'] = new TimberMenu();
$posts = Timber::get_posts('TimberPost');
$data['posts'] = $posts;
$data['foo'] = 'bar';
$templates = array('index.twig');
if (is_home()){
array_unshift($templates, 'home.twig');
Expand Down
1 change: 1 addition & 0 deletions timber-starter-theme/views/index.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% extends "base.twig" %}

{% block content %}
<h2>{{foo}}</h2>
{% for post in posts %}
{% include ['tease-'~post.post_type~'.twig', 'tease.twig'] %}
{% endfor %}
Expand Down

0 comments on commit bd096af

Please sign in to comment.