PHPackages                             wol-soft/php-micro-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. wol-soft/php-micro-template

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

wol-soft/php-micro-template
===========================

A minimalistic templating engine for PHP

1.10.2(2mo ago)16128.4k↓17.3%21MITPHPPHP &gt;=7.1CI passing

Since Apr 27Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/wol-soft/php-micro-template)[ Packagist](https://packagist.org/packages/wol-soft/php-micro-template)[ Docs](https://github.com/wol-soft/php-micro-template)[ RSS](/packages/wol-soft-php-micro-template/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (18)Used By (1)

[![Latest Version](https://camo.githubusercontent.com/0487833a55a17d489fa48b9e56f2da3f88fb19df6c0e2a5b097c5e0a87245b73/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f776f6c2d736f66742f7068702d6d6963726f2d74656d706c6174652e737667)](https://packagist.org/packages/wol-soft/php-micro-template)[![Maintainability](https://camo.githubusercontent.com/ffa40d22a61b2872a1bee3bcdf27662050ffaef7a9ca2c1c9095ec6f73481fc5/68747470733a2f2f716c74792e73682f67682f776f6c2d736f66742f70726f6a656374732f7068702d6d6963726f2d74656d706c6174652f6d61696e7461696e6162696c6974792e737667)](https://qlty.sh/gh/wol-soft/projects/php-micro-template)[![Build Status](https://github.com/wol-soft/php-micro-template/actions/workflows/main.yml/badge.svg)](https://github.com/wol-soft/php-micro-template/actions/workflows/main.yml)[![Coverage Status](https://camo.githubusercontent.com/6549f731efabd9970c9fd94745d6492bf701d9b1f8afc13e48e727f3f524d8ee/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f776f6c2d736f66742f7068702d6d6963726f2d74656d706c6174652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/wol-soft/php-micro-template?branch=master)[![MIT License](https://camo.githubusercontent.com/382f4ecc028251c5df17d6b483db97b16fa02f13670e7fe99935ed0c8eff51e6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f776f6c2d736f66742f7068702d6d6963726f2d74656d706c6174652e737667)](https://github.com/wol-soft/php-micro-template/blob/master/LICENSE)

php-micro-template
==================

[](#php-micro-template)

A minimalistic, lightweight templating engine for PHP with zero dependencies based on regular expressions.

Features
--------

[](#features)

- Replace variables inside a template
- Iterate over an array or iterable object
- Conditional sections
- Pass objects
- call functions

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

[](#requirements)

- Requires at least PHP 7.1

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

[](#installation)

The recommended way to install php-micro-template is through [Composer](http://getcomposer.org):

```
$ composer require wol-soft/php-micro-template

```

Examples
--------

[](#examples)

First create your template file:

```

    {{ pageTitle }}

        {% foreach products as product %}
            {% if product.isVisible() %}

                    {{ productHead }}
                    {{ product.getTitle() }}

            {% endif %}
        {% endforeach %}

    {% if showVersion %}
        1.0.1
    {% endif %}

```

Afterwards create a new instance of the Render class and render your template:

```
