PHPackages                             reinvanoyen/aegis - 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. reinvanoyen/aegis

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

reinvanoyen/aegis
=================

Extendable template engine

0.0.5(6y ago)111921PHPPHP ^7.1CI failing

Since Dec 19Pushed 1y ago1 watchersCompare

[ Source](https://github.com/reinvanoyen/aegis)[ Packagist](https://packagist.org/packages/reinvanoyen/aegis)[ RSS](/packages/reinvanoyen-aegis/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (5)Dependencies (2)Versions (6)Used By (1)

 [ ![](https://raw.githubusercontent.com/reinvanoyen/aegis/master/logo.png) ](https://github.com/reinvanoyen/aegis)

### The flexible and extendable PHP templating language

[](#the-flexible-and-extendable-php-templating-language)

[![Build Status](https://camo.githubusercontent.com/95ecd47f155f83df5b8f423bb0c6a5a6c4f11980c2e9785eae43d04db630af36/68747470733a2f2f7472617669732d63692e6f72672f7265696e76616e6f79656e2f61656769732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/reinvanoyen/aegis)

Important: Experimental software
--------------------------------

[](#important-experimental-software)

Aegis is still in experimental mode, which means using this in production might not be the best idea. Please consider [contributing](#contributing) if you want to make this software more stable.

### Introduction

[](#introduction)

**Aegis is a flexible, dynamic templating language.** It aims to be truly extendable. It comes with a default set of functionalities to help you with the basics of creating web layouts (template inheritance, printing data, iteration helpers, etc). However, if you decide to implement your own nodes and use it as a language with a completely different purpose, you're encouraged to do so.

### Installation

[](#installation)

```
composer require reinvanoyen/aegis

```

### Default runtime documentation

[](#default-runtime-documentation)

- [Printing data](#printing-data)
- [Block](#block)
- [Extends](#extends)
- [If, else and elseif](#if-else-and-elseif)
- [For](#for)
- Raw
- Include

#### Printing data

[](#printing-data)

```

    John Doe
    {{ @name }}
    {{ 'John Doe' }}
    {{ "John Doe" }}
    {{ "John " + @lastname }}
    {{ @firstname + ' ' + @lastname }}

```

#### Block

[](#block)

The `block` tag defines a container which can hold more template code. Each time a block tag is used, the content of that container is outputted.

```
{{ block "title" }}Aegis{{ /block }}
{{ block "baseline" }}The template language{{ /block }}
```

In the above example two block tags, each with a unique name, were used. The above would output:

```
Aegis
The template language
```

This is nothing spectacular, it get more interesting as we modify the contents of these blocks by using the options `append` or `prepend` like in the example below.

```
{{ block "title" }}Aegis{{ /block }}
{{ block "baseline" }}template language{{ /block }}

{{ block "title" append }}...{{ /block }}
{{ block "baseline" prepend }}The {{ /block }}

```

The above example modifies the contents of the "title" and "baseline" block by appending and prepending content. The output would be:

```
Aegis...
The template language
Aegis... The template language
```

Remember that every use of the block tag also outputs the content, even if the tag modifies the content. All modifications to the content of a block are executed first, so the output of a block will always be the output after all the modifications have executed. This can be confusing at first, but once you get the hang of it, it can provide you with great flexibility.

The contents of a block can be completely overwritten by simply using the block tag with new content, like so:

```
{{ block "title" }}{{ /block }}
{{ block "baseline" }}template language{{ /block }}

{{ block "title" }}Aegis{{ /block }},
{{ block "baseline" prepend }}The {{ /block }}

```

This would output:

```
Aegis
The template language
Aegis, The template language
```

Emptying a block is possible by using the block tag with no content at all:

```
{{ block "title" }}Aegis{{ /block }}
{{ block "title" }}{{ /block }}
```

The above example would simply output nothing at all.

#### Extends

[](#extends)

The `extends` tag brings in a template from another file, provides functionality to manipulate the blocks provided by that template and outputs the results. In comparison to many template engines an Aegis template is not limited to one extends tag. This makes it possible to use the extends tag as some sort of mixin, like in the example below where the header and footer templates are used as smaller parts of the bigger picture.

header.tpl

```

    {{ block "title" }}{{ /block }}

```

footer.tpl

```

    &copy; 2016 Aegis

```

layout.tpl

```
{{ extends "header" }}
    {{ block "title" }}Aegis, the template language{{ /block }}
{{ /extends }}

Content could go here

{{ extends "footer" }}{{ /extends }}
```

While it's perfectly fine to restrict yourself to only extend from one template at a time, just like you could in other popular template engines, splitting up you templates in smaller parts like demonstrated above could give you advantages in flexibility later on. Since expressions in the default runtime of Aegis are evaluated at runtime, we could do something like this:

home-header.tpl

```

    Welcome to my website: {{ block "title" }}{{ /block }}

```

default-header.tpl

```

            {{ block "title" }}{{ /block }}

```

layout.tpl

```

    {{ extends @page+"-header" }}
        {{ block "title" }}Aegis, the template language{{ /block }}
    {{ /extends }}

```

The layout template would now extend one of the header templates based on the value of the variable "page", for instance when the header should be different for each page of a website.

#### If, else and elseif

[](#if-else-and-elseif)

The `if` tag allows for conditional rendering within templates.

```
{{ if @show }}Show this content{{ /if }}
```

```
{{ if @show }}
    Show this
{{ else }}
    Nothing to show
{{ /if }}
```

```
{{ if @title equals "Aegis" }}
    {{ @title }}
{{ elseif @number equals 5 or @number equals 10 }}
    The title is not Aegis, but the number is {{ @number }}
{{ else }}
    The title is not Aegis nor is the number 5 or 10
{{ /if }}
```

#### For

[](#for)

```
{{ for @contributor in ['Rein Van Oyen'] }}
    {{ @contributor }}
{{ /for }}
```

```
{{ for @contributor in @contributors }}
    {{ @contributor }}
{{ /for }}
```

```

    {{ for 0 to 10 }}
        Aegis
    {{ /for }}

```

```

    {{ for 0 to 10 as @index }}
        Aegis #{{ @index }}
    {{ /for }}

```

### Creating your own runtime

[](#creating-your-own-runtime)

Coming soon...

### Contributing

[](#contributing)

Feel free to contribute to Aegis, any help is greatly appreciated. Please keep your coding style compatible with [PSR-2](http://www.php-fig.org/psr/psr-2/) and back your code with unit tests.

### License

[](#license)

Aegis is open-sourced software licensed under the [BSD-3-Clause](https://github.com/reinvanoyen/aegis/blob/master/LICENSE).

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 99.3% 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

Every ~0 days

Total

5

Last Release

2384d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/df8bd7df61e167c70211a2b9b0e44d8db71a4197992f57d694aafbd4aca47914?d=identicon)[reinvanoyen](/maintainers/reinvanoyen)

---

Top Contributors

[![reinvanoyen](https://avatars.githubusercontent.com/u/513140?v=4)](https://github.com/reinvanoyen "reinvanoyen (147 commits)")[![gitter-badger](https://avatars.githubusercontent.com/u/8518239?v=4)](https://github.com/gitter-badger "gitter-badger (1 commits)")

---

Tags

compilerlanguagelexerparserphptemplatetemplate-languagetemplate-librarytemplatestpltemplatingtemplate engine

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/reinvanoyen-aegis/health.svg)

```
[![Health](https://phpackages.com/badges/reinvanoyen-aegis/health.svg)](https://phpackages.com/packages/reinvanoyen-aegis)
```

###  Alternatives

[twig/twig

Twig, the flexible, fast, and secure template language for PHP

8.4k457.8M6.8k](/packages/twig-twig)[mustache/mustache

A Mustache implementation in PHP.

3.3k46.6M313](/packages/mustache-mustache)[smarty/smarty

Smarty - the compiling PHP template engine

2.4k40.9M448](/packages/smarty-smarty)[laminas/laminas-view

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

7527.7M261](/packages/laminas-laminas-view)

PHPackages © 2026

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