Home - maxcal/Twigpress GitHub Wiki
Twigpress
Twig + Wordpress = Twigpress
Twigpress is a wordpress plugin that allows template designers to create wordpress templates with Twig.
Twig is a PHP template engine with great functionality and syntax.
Multi-paradigm design.
Twigpress is created with alot of flexiblity in mind.
As a drop in replacement for PHP.
When used with template autoloading and registerGlobalFunctions twigpress can be used as a drop in syntax replacement for php.
// /themes/yourTheme/index.php
$Twigpress->registerGlobalFunctions();
echo $Twigpress->autoDisplay($wp_query);
Renders:
{# themes/yourTheme/index.html.twig #}
Hello {{ bloginfo( 'name' ) }}
As Model View Controller
You can use it as MVC by using the index.php (Controller)
to set posts (Model)
and renderindex.html.twig (view)
// index.php
$my_query = new WP_Query('posts_per_page=10');
$Twigpress->display('index.html.twig', array('posts' => $my_query));
Coding Conventions:
-
Convention over Configuration
Defaults should be as secure and useful as possible on a live site. [@todo] - the ideas is Themes can declare there own configuration (via ini or json) which will override the plugin config. -
Dependency Injection
Use inversion of control and dependency injection when possible. Avoid using WP globals or functions directly if possible. -
TDD
All public methods should be unit tested. -
File naming
Use the PEAR conventions, not the Wordpress Conventions.
Mission:
- To make it fun and creative to create wordpress themes with Twig.
- To be tested and reliable.
- To offer flexibility to theme designers.