Download the PHP package mezon/html-template without Composer
On this page you can find all versions of the php package mezon/html-template. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mezon/html-template
More information about mezon/html-template
Files in mezon/html-template
Package html-template
Short Description Small html-template script
License MIT
Homepage https://github.com/alexdodonov/mezon-html-template
Informations about the package html-template
HTML template class
This class provides routine for HTML pages generation. Works fast and quite simple in use.
It is a part of Mezon Framework and used in the Application class
Learn more
More information can be found here:
I'll be very glad if you'll press "STAR" button )
Installation
Just type
Usage
Paths to template files
First of all you need to create object.
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 template files.
No need to specify all paths in the constructor. You can do it later with methods:
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:
And view a list of paths:
Setup layout
You can have different layouts for your pages:
Layout will let you to define different templates for your different purposes.
You can create in your template as much layouts as you need. Just add files:
Setup blocks
After the layout was setup you can pass blocks to the template.
It will allow you to put different content in your layout.
For example:
That means that HtmlTemplate
class will get the file %template-sources%/Res/Blocks/%block-name%.tpl
and put instead the placeholder {%block-name%}
within your layout.
But you can place the block in any placeholder you need:
If you have $var=foo
then your placeholder must be {foo}
Setting vars
You can also pass almost any data to the template
Compile template
Just call
The method will return a compiled page wich you can send to user of your application.