PHP Classes


Recommend this page to a friend!
  Classes of Alexey Dodonov   Mezon PHP HTML Template Engine   Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: Mezon PHP HTML Template Engine
Process HTML templates replacing variables
Author: By
Last change:
Date: 2 years ago
Size: 1,652 bytes


Class file image Download

HTMP template class

Build Status codecov Scrutinizer Code Quality


Just type

composer require mezon/html-template


First of all you need to create object

$template = new \Mezon\HtmlTemplate\HtmlTemplate('./main-template/');

This code assumes that you have all template resources in the directory './main-template/'

But you can also specify a list of paths, and while template compilation they all will be scanned for static files.

$template = new \Mezon\HtmlTemplate\HtmlTemplate(['./main-template/', './extra-files/res/']);

No need to specify all paths in the constructor. You can do it later with methods:

$template = new \Mezon\HtmlTemplate\HtmlTemplate('./main-template/');
$template->addPaths(['./path1', './path2']);

But be carefull if you have static files with the same names on different paths. While compilation the file on the latest added path will be used. It was done so to create a sort of overriding mechanism for template resources.

Or you can completely reset all paths:

$template->setPaths(['./path1', './path2']);

And view a list of paths: