Key Features
Every tool has its advantages and disadvantages – a well-designed tool is one built to meet a specific need and to improve the experience and the outcome of the task that it is intended to be used for.
Willow was built to improve the experience of both back-end and front-end developers, here are a few key reason how:
- Small tag library is easy to learn, use and control
- Logic-less templates ensure a clean separation of concerns, all logic lives in controllers
- Limited access to PHP functions and variables provides better UI development experience
- Portable and re-usable features via template, array and file configuration
- Built-in support for WordPress, Advanced Custom Fields, extensible and plays nicely with other themes and plugins
WordPress Plugin
Currently this project is developed in the format of a WordPress plugin and has WordPress as a dependency ( using several top-level WordPress functions ), but can eventually be ported to a stand-alone system once more stable and given sufficient demand.
To use willow templates in your project, you will need to install this plugin, then create a template file with a .willow extension and select this template via the WordPress editor, for example:
page.willow
These documentation pages will attempt to demonstrate some common use-cases of Willow as well as documenting its syntaxes and internal workings.
Hello Willow
All Willow tags include a matching opening and closing pair, starting and ending with a curly bracket and one other internal character.
Follows a totally useless, but no-less classic example of how to get started with Willow:
{~ ui~hello {+ <div>Willow says {{ hello }}</div> +} ~}
This tag calls the PHP public method ui->hello() and Willow wraps the returned data in the passed markup HTML:
class ui {
function hello( $args = null ) {
// define key + value to render ##
return [
'hello' => 'Hello'
];
}
}
Which returns the following output from the template:
<div>Willow says Hello</div>