PHPackages                             sitepoint/templating-engine - 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. sitepoint/templating-engine

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

sitepoint/templating-engine
===========================

A simple, easy to follow PHP templating engine

v0.1.0(10y ago)311[1 issues](https://github.com/sitepoint/TemplatingEngine/issues)MITPHP

Since Oct 26Pushed 10y ago3 watchersCompare

[ Source](https://github.com/sitepoint/TemplatingEngine)[ Packagist](https://packagist.org/packages/sitepoint/templating-engine)[ Docs](https://github.com/sitepoint/TemplatingEngine)[ RSS](/packages/sitepoint-templating-engine/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

[![SitePoint](https://avatars2.githubusercontent.com/u/15340853?v=3&s=40)](https://avatars2.githubusercontent.com/u/15340853?v=3&s=40) Templating Engine
========================================================================================================================================================

[](#-templating-engine)

[![Latest Stable Version](https://camo.githubusercontent.com/eb2f3bfe6af52825117a29b455938dd64f9faf48e0c0e6d41423085e4a8db219/68747470733a2f2f706f7365722e707567782e6f72672f73697465706f696e742f74656d706c6174696e672d656e67696e652f762f737461626c65)](https://packagist.org/packages/sitepoint/templating-engine)[![Build Status](https://camo.githubusercontent.com/f2491c91ac7dfbec5a44c85ab74da7823fba8c5cae8ef80662c0625f4484d17e/68747470733a2f2f7472617669732d63692e6f72672f73697465706f696e742f54656d706c6174696e67456e67696e652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/sitepoint/TemplatingEngine)[![Code Coverage](https://camo.githubusercontent.com/55fff165afa9ec640f5719d714049acc95857ecc7a57ffa7e5fdc0b06fb9582c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73697465706f696e742f54656d706c6174696e67456e67696e652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/sitepoint/TemplatingEngine/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/6eb9f80b4abf9755668d7c15df554d1761362335659e6acce4f7c4d57511c0e4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73697465706f696e742f54656d706c6174696e67456e67696e652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/sitepoint/TemplatingEngine/?branch=master)[![Code Climate](https://camo.githubusercontent.com/ebda71363873bb3630ef9f6df249ae8f296d977b62d937cf62d5ad0363841b45/68747470733a2f2f636f6465636c696d6174652e636f6d2f7265706f732f3536326635616232363935363830346632393030323162322f6261646765732f35643964306666333165323665306261336339642f6770612e737667)](https://codeclimate.com/repos/562f5ab26956804f290021b2/feed)[![Total Downloads](https://camo.githubusercontent.com/e85f385d12d01581ad1a9ecff02b785bb2c855935e6112cbad29bca2906c6716/68747470733a2f2f706f7365722e707567782e6f72672f73697465706f696e742f74656d706c6174696e672d656e67696e652f646f776e6c6f616473)](https://packagist.org/packages/sitepoint/templating-engine)[![License](https://camo.githubusercontent.com/54eaa2e8c145f1a117364dc37b7a588d4f3e8cc785ffbabe295d0b5c31026fb1/68747470733a2f2f706f7365722e707567782e6f72672f73697465706f696e742f74656d706c6174696e672d656e67696e652f6c6963656e7365)](https://packagist.org/packages/sitepoint/templating-engine)

A simple, easy to follow PHP templating engine. Designed to be forked, modified, extended and hacked.

Example Usage
-------------

[](#example-usage)

This templating engine supports inheritance through blocks. Child templates declare blocks which can be overridden, extended and displayed by parent templates.

Child templates can declare a single parent template at any point using the `parent()` method which also provides the opportunity to modify the variables that are in scope.

All templates must follow the `namespace::path/to/template` format.

```

```

```

        escape($title);?>

        block('content');?>

```

Namespaces and function callbacks are registered with the templating engine when it is constructed. Function callbacks are available as methods within the template context and must be `callable`.

The default template extension is `phtml`, but this can be overridden.

```
use SitePoint\TemplatingEngine\TemplatingEngine;

$engine = new TemplatingEngine(
    ['app'  => '/path/to/templates/app'], // The namespaces to register
    ['caps' => 'strtoupper'],             // Function callbacks to register inside the template context
    'phtml'                               // The extension of the templates (defaults to phtml)
);

$params = [
    'title' => 'My Blog Post',
    'paragraphs' => [
        'My first paragraph.',
        'My second paragraph.',
    ],
];

echo $engine->render('app::post', $params);
```

Template Context Methods
------------------------

[](#template-context-methods)

The following methods are available by default within the template context.

```
/**
 * Define a parent template.
 *
 * @param string $template The name of the parent template.
 * @param array  $params   Parameters to add to the parent template context
 *
 * @throws EngineException If a parent template has already been defined.
 */
public function parent($template, array $params = []);
```

```
/**
 * Insert a template.
 *
 * @param string $template The name of the template.
 * @param array  $params   Parameters to add to the template context
 */
public function insert($template, array $params = []);
```

```
/**
 * Render a block.
 *
 * @param string $name The name of the block.
 */
public function block($name, callable $callback = null);
```

```
/**
 * Escape a string for safe output as HTML.
 *
 * @param string $raw The unescaped string.
 *
 * @return string The escaped HTML output.
 */
public function escape($raw);
```

Authors
-------

[](#authors)

- [Andrew Carter](https://twitter.com/AndrewCarterUK)

Change Log
----------

[](#change-log)

This project maintains a [change log file](CHANGELOG.md)

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE](LICENSE) for more information.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3856d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4c1fbd2989c3dc9eba2c45f72fe4727d5cf1bde9ef6ff014c2b961e95636a6dc?d=identicon)[swader](/maintainers/swader)

![](https://www.gravatar.com/avatar/6e7abce428a9dc9c76f4275ca8d8d11ad55138d72f3e3e2b01c6b2da5b479cc0?d=identicon)[AndrewCarterUK](/maintainers/AndrewCarterUK)

![](https://www.gravatar.com/avatar/9eeae727b2e891f5298165e913fc7f1f8a73fcafa5f979b39680c6ba7da66878?d=identicon)[sitepoint-repo-tools](/maintainers/sitepoint-repo-tools)

---

Top Contributors

[![AndrewCarterUK](https://avatars.githubusercontent.com/u/6486835?v=4)](https://github.com/AndrewCarterUK "AndrewCarterUK (38 commits)")[![sitepoint-repo-tools](https://avatars.githubusercontent.com/u/15340853?v=4)](https://github.com/sitepoint-repo-tools "sitepoint-repo-tools (4 commits)")

---

Tags

templatingtemplatesengine

### Embed Badge

![Health badge](/badges/sitepoint-templating-engine/health.svg)

```
[![Health](https://phpackages.com/badges/sitepoint-templating-engine/health.svg)](https://phpackages.com/packages/sitepoint-templating-engine)
```

###  Alternatives

[league/plates

Plates, the native PHP template system that's fast, easy to use and easy to extend.

1.5k5.9M232](/packages/league-plates)[laminas/laminas-view

Fast and type safe HTML templating library with a flexible plugin system supporting multistep template composition

7526.3M230](/packages/laminas-laminas-view)[mobicms/render

Native PHP template engine

106.7k1](/packages/mobicms-render)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
