Skip to content
Lukas Jans edited this page Mar 30, 2023 · 2 revisions

Colony is an HTML template engine for PHP, that intuitively extends the fundamental markup concepts of HTML. Its objective is to make element attributes (and more) dynamic, without the need to embed code into HTML documents. With Colony, this can be done by just adding supplementary attributes to the desired elements, while staying in the realm of familiar HTML syntax. Such a template plus a raw dataset are then combined to an individual HTML document by the Colony engine.

In theory, the principle of attributes is generalized to so-called attribute stacks, that are actually collections of multiple attributes with basically the same name. This is achieved by defining different levels of attributes according to the amount of colons : prepending their normalized name to allow for more than just one attribute value per normalized name. That means all conventional attributes are now interpreted as attributes of level 0 (because of no prepending colons).

By design, each valid HTML document is also a valid Colony template. That makes it possible to keep using original attributes alongside new attribute stacks enriched with further levels. A typical element in a Colony template may then look like this:

<input class="test" value="level0" :value="level1" ::value="level2">

Of course this template has to be processed by the Colony engine first, before sending it to a browser. In doing so, all attribute stacks will be extracted from the corresponding elements and processed by so-called handlers. These are small software plugins that combine an attribute stack with the provided dataset to form a part of the final HTML document. The set of handlers can easily be restricted or extended with custom logic for specific attributes.

One handler is directly built into the engine, because it represents Colony's core functionality: Setting attribute values depending on the given dataset. Learn more about this in the next chapter or click another link in the table of contents to continue reading.

Clone this wiki locally