PHPackages                             icybee/patron - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. icybee/patron

ActiveLibrary[Templating &amp; Views](/categories/templating)

icybee/patron
=============

A HTML template engine

v1.4.1(9y ago)270313BSD-3-ClausePHPPHP ^5.5|^7.0

Since Mar 11Pushed 4y ago2 watchersCompare

[ Source](https://github.com/Icybee/Patron)[ Packagist](https://packagist.org/packages/icybee/patron)[ Docs](https://github.com/Icybee/Patron)[ RSS](/packages/icybee-patron/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (3)Versions (11)Used By (3)

Patron
======

[](#patron)

[![Release](https://camo.githubusercontent.com/5c65379771917b105625139fe353b5e99fea95b37b5484a0ce4f328aef20ca46/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6963796265652f706174726f6e2e737667)](https://packagist.org/packages/icybee/patron)[![Build Status](https://camo.githubusercontent.com/30f292ed1b3ec9038001629cdc390de7fdf4b7b612e96255460fc8b6daca6bab/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f4963796265652f506174726f6e2e737667)](http://travis-ci.org/Icybee/Patron)[![HHVM](https://camo.githubusercontent.com/02e5c9062ed45352506c0a72a9299567031cf1a7a31de30dda6a7ba01a1df4b4/68747470733a2f2f696d672e736869656c64732e696f2f6868766d2f4963796265652f506174726f6e2e737667)](http://hhvm.h4cc.de/package/Icybee/Patron)[![Code Quality](https://camo.githubusercontent.com/60380c256f1a935df3a6240cd376388d7beb475994ae211fc1bbd0f59d846f1a/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f4963796265652f506174726f6e2e737667)](https://scrutinizer-ci.com/g/Icybee/Patron)[![Code Coverage](https://camo.githubusercontent.com/10d385d01da941b82da8e07b8f4a809a4abd49d36469592e5328058a6b292a08/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f4963796265652f506174726f6e2e737667)](https://coveralls.io/r/Icybee/Patron)[![Packagist](https://camo.githubusercontent.com/9747ae5346dd1e976900c5b2e249267b480c6c4276aace1d9f3dbfde0337e0ee/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f4963796265652f506174726f6e2e737667)](https://packagist.org/packages/Icybee/Patron)

**Patron** is a template engine for PHP5.4+. It facilitates the separation of the application logic and content from its presentation. Templates are written in HTML and include expressions that are replaced as the template is parsed, and special markups that control the logic of the template.

### A typical example

[](#a-typical-example)

```

			#{@title}

			#{@=}

					Comments

							Comment №#{self.position} by #{@author}

							#{@=}

```

### Features

[](#features)

- The markup set and the function set are easily extensible.
- Blocks have a *subject*, similar to how `this` works in javascript.
- Easy to translate using the `#{t:String to translate}` notation.

### Acknowledgment

[](#acknowledgment)

This template engine was developed because around 2007 [textpattern](http://textpattern.com/)didn't support nested markups, and I though it would be a good exercise. Some part of its code have slept for a long time, so don't be surprise if you see some camel casing although snake casing is used nearly everywhere, at least you'll recognize the *old* parts :-)

Expressions
-----------

[](#expressions)

Expressions, using the `#{}` notation, are used to output data. The data is always escaped unless the `=` modifier is used, just before the closing `}`. The `@` sign is used to access the properties of the *subject* (although you can also use `this`).

```
#{@title}
#{@title.shuffle()}
#{@title=}

#{pagination=}
```

Markup collection
-----------------

[](#markup-collection)

The markups that can be used by a *Patron* engine instance are defined in a [MarkupCollection](lib/MarkupCollection.php)instance, which is used to create the [Engine](lib/Engine.php) instance. The `get_markups()` helper function can be used to obtain a shared markup collection. When it is first created, the `MarkupCollection::alter` event of class [MarkupCollection\\AlterEvent](lib/MarkupCollection/AlterEvent.php) is fired. Event hooks may use this event to alter the collection, adding and removing markups definitions.

The following example demonstrates how an event hook may be used to add a `hello` markup, that supports a `name` argument which defaults to "world":

```
