TwigPress is a Wordpress theme which is based upon Twig Engine. Probably it could be flagged also as "another Twig Engine Theme for Wordpress".
TwigPress was born with ease in mind, cleaner APIs and ease to extended. Well, kind-of for now :)
Basically you only have to work inside "templates" directory. You do not have to touch anything at all.
If you need to enable/disable Debug function on Twig you just have to change TwigPress_Debug
define to true
or false
.
By default it will always be enabled. Keep in mind that if you enable it you'll have cache disabled, if enabled, cache will be enabled.
In fact there's not much to explain. When you want to run TwigPress in your template file you just have to do something like
<?php new TwigPress(array(/* your arguments here */)); ?>
and the arguments you can use until now are:
vars
: your custom template variables you could use on your .twig templates within thetplapi
keyword.
<?php new TwigPress(array( "vars" => array( "myname" => "Author name", "mysurname" => "Author surname" ) )); ?>
TwigPress comes with three main API keywords:
-
wpapi
this is the most wonderful API which TwigPress comes in mind with. It is the entry point to access Wordpress Core APIs. So anywpapi.your_api_call_here
is exactly you was used to do with templates until now. -
twpapi
this is the main TwigPress API entry point of the next future releases. For now you'll have just these APIs:base_uri
this is the base URL which points to your theme installation inside the "templates/" directory.template_name
this is the current template name which Wordpress required.fn
this will be the entry point to custom function of TwigPress. Until now they are:addCss
this is a custom function to enqueue your CSS in Wordpress. Useful for other plugins if you want let them to compact your CSS for example.addJs
same asaddCss
but this time for Javascript files.
-
tplapi
this will be your custom vars that you'll pass to TwigPress when you initialize your Class.
{# Wordpress API call #} Wordpress Name: {{ wpapi.get_bloginfo('name') }} Wordpress Description: {{ wpapi.get_bloginfo('description') }} {# TwigPress API call #} Current template: {{twpapi.template_name }} {# Template API call #} My name: {{ tplapi.myname }} My Surname: {{ tplapi.mysurname }}
This project is covered up by MIT license. You can find it attached to any .php file and the LICENSE file itself. Please keep it open as much as you can :)