Mezon PHP HTML Template Engine: Process HTML templates replacing variables

Recommend this page to a friend!
  Info   View files Documentation   View files View files (14)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-07-07 (2 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 72 This week: 1All time: 9,680 This week: 267Up
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: 17 packages by
Country: Russian Federation Russian Federation
Age: ???
All time rank: 310283 in Russian Federation Russian Federation
Week rank: 17 Up3 in Russian Federation Russian Federation Up
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 folder image Files  
File Role Description
Files folder imageTests (2 files, 2 directories)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Plain text file HtmlTemplate.php Class Class source
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation
Plain text file TemplateResources.php Class Class source

  Files folder image Files  /  Tests  
File Role Description
Files folder imageres (1 file, 1 directory)
Files folder imagetest-data (1 directory)
  Plain text file HtmlTemplateUnitTest.php Class Class source
  Plain text file TemplateResourcesUnitTest.php Class Class source

  Files folder image Files  /  Tests  /  res  
File Role Description
Files folder imagetemplates (1 file)
  Accessible without login Plain text file var.txt Doc. Documentation

  Files folder image Files  /  Tests  /  res  /  templates  
File Role Description
  Accessible without login HTML file index.html Doc. Documentation

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

  Files folder image Files  /  Tests  /  test-data  /  res  
File Role Description
Files folder imageblocks (1 file)
Files folder imagetemplates (1 file)
  Accessible without login HTML file index2.html Doc. Documentation

  Files folder image Files  /  Tests  /  test-data  /  res  /  blocks  
File Role Description
  Accessible without login Plain text file main.tpl Data Auxiliary data

  Files folder image Files  /  Tests  /  test-data  /  res  /  templates  
File Role Description
  Accessible without login HTML file index.html Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:72
This week:1
All time:9,680
This week:267Up

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