Mezon PHP HTML Template Engine: Process HTML templates replacing variables

Recommend this page to a friend!
  Info   Documentation   View files (14)   Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-07-07 (29 days ago) Not yet rated by the usersTotal: 67 This week: 2All time: 9,691 This week: 114
Version License PHP version Categories
mezon-html-template 1.0MIT/X Consortium ...5HTML, PHP 5, Templates
Description Author

This package can be used process HTML templates replacing variables.

It takes a given template to be loaded from a directory and processes it by replacing template marks with variables values that can be passed to the main template class.

The package can take a list of directory paths from which it can read the template files.

It supports template blocks that define separate sections of the template.

The package also supports resources that define CSS and JavaScript resources to be linked to external files.

Picture of Alexey Dodonov
  Performance   Level  
Name: Alexey Dodonov <contact>
Classes: 13 packages by
Country: Russian Federation Russian Federation
Age: ???
All time rank: 334891 in Russian Federation Russian Federation
Week rank: 3 1 in Russian Federation Russian Federation
Innovation award
Innovation award
Nominee: 1x

Details

HTMP template class

Build Status codecov Scrutinizer Code Quality

Installation

Just type

composer require mezon/html-template

Usage

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:

var_dump($template->getPaths());
  Files  
File Role Description
Tests (2 files, 2 directories)
.travis.yml Data Auxiliary data
composer.json Data Auxiliary data
composer.lock Data Auxiliary data
HtmlTemplate.php Class Class source
phpunit.xml Data Auxiliary data
README.md Doc. Documentation
TemplateResources.php Class Class source

  Files  /  Tests  
File Role Description
res (1 file, 1 directory)
test-data (1 directory)
   HtmlTemplateUnitTest.php Class Class source
   TemplateResourcesUnitTest.php Class Class source

  Files  /  Tests  /  res  
File Role Description
templates (1 file)
   var.txt Doc. Documentation

  Files  /  Tests  /  res  /  templates  
File Role Description
   index.html Doc. Documentation

  Files  /  Tests  /  test-data  
File Role Description
res (1 file, 2 directories)

  Files  /  Tests  /  test-data  /  res  
File Role Description
blocks (1 file)
templates (1 file)
   index2.html Doc. Documentation

  Files  /  Tests  /  test-data  /  res  /  blocks  
File Role Description
   main.tpl Data Auxiliary data

  Files  /  Tests  /  test-data  /  res  /  templates  
File Role Description
   index.html Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:67
This week:2
All time:9,691
This week:114

For more information send a message to info at phpclasses dot org.