Willow

Introduction

Willow has been designed to meet the needs of both front-end and back-end developers by providing a small, yet powerful set of tags and tools to speed up template development and prototype iteration, and is influenced by other template engines, most notably Mustache.
Version 1.4.8
Latest Changes:

* New: html_entity_decode filter


Documentation about each release is updated as often as possible, but may lag behind the Master Branch or other generated documentation.

Featured Work
Quinta de Sant’Ana, Portugal
Quinta de Sant’Ana, Portugal

Quinta de Sant'Ana overlooks the picturesque village of Gradil with its cobbled streets, white washed houses and hospitable inhabitants.


Key Features

Every tool has it’s 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:

test.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 {

	public static 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>