PHPackages                             dahas/easy-template - 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. dahas/easy-template

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

dahas/easy-template
===================

A PHP Template Parser

v1.1.0(3y ago)014GPL-3.0-or-laterPHP

Since Mar 7Pushed 3y ago1 watchersCompare

[ Source](https://github.com/dahas/EasyTemplate)[ Packagist](https://packagist.org/packages/dahas/easy-template)[ RSS](/packages/dahas-easy-template/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

EasyTemplate
============

[](#easytemplate)

EasyTemplate is a PHP Template Parser that consequently seperates logic from the view. It simply replaces marked areas of an HTML file with content generated by a controller script.

Requirements
------------

[](#requirements)

PHP 8.1.2

Installation
------------

[](#installation)

```
$ composer require dahas/easy-template

```

Example
-------

[](#example)

Templates are either complete HTML files or HTML segments that contain markers and slices.

```
DOCTYPE html>

        [[TITLE]]

        [[HEADER]]

                    #
                    NAME
                    AGE
                    CITY

                    [[UID]]
                    [[NAME]]
                    [[AGE]]
                    [[CITY]]

```

Here is how you load a template:

```
$template = new EasyTemplate("path/to/template.html");
```

### Markers

[](#markers)

Markers are placeholders. They'll be replaced with content when the HTML template gets parsed. A marker is surrounded by double square brackets, like so: `[[MARKER]]`

### Slices

[](#slices)

A slice is an HTML segment within a template. It is defined by two markers, one at the beginning and one at the end of the segment. Both slice-markers are wrapped twice in curly braces. You can additionally wrap them in comments:

```

    [[UID]]
    [[NAME]]
    [[AGE]]
    [[CITY]]
    [[COUNTRY]]

```

Slices are treated like Templates. You can even put a Slice in its own HTML file.

Getting the Slice within a Template:

```
$slice = $this->template->getSlice("ROWS");
```

Loading the Slice from its own file:

```
$slice = new EasyTemplate("path/to/slice.html");
```

### Parsing Markers and Slices

[](#parsing-markers-and-slices)

To replace Markers and Slices and return a valid HTML document you use the `parse()` method. This function takes an Array of Markers as the first and an Array of Slices as the second argument.

```
$template = new EasyTemplate("path/to/template.html");

$markers = [
    "TITLE" => "The title",
    "HEADER" => "Easy Template is cool!"
];

$slice = $template->getSlice("ROWS");

$rows = $slice->parse([
    "UID" => 1,
    "NAME" => "Angus Young",
    "AGE" => 66,
    "CITY" => "Melbourne",
]);

$slices = [
    "ROWS" => $rows
];

return $template->parse($markers, $slices);
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~6 days

Total

2

Last Release

1161d ago

### Community

Maintainers

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

---

Top Contributors

[![dahas](https://avatars.githubusercontent.com/u/9695935?v=4)](https://github.com/dahas "dahas (15 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dahas-easy-template/health.svg)

```
[![Health](https://phpackages.com/badges/dahas-easy-template/health.svg)](https://phpackages.com/packages/dahas-easy-template)
```

###  Alternatives

[mustache/mustache

A Mustache implementation in PHP.

3.3k44.6M291](/packages/mustache-mustache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[nicmart/string-template

StringTemplate is a very simple string template engine for php. I've written it to have a thing like sprintf, but with named and nested substutions.

2101.7M30](/packages/nicmart-string-template)

PHPackages © 2026

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