1. Go to this page and download the library: Download mezon/html-template library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mezon / html-template example snippets
use Mezon\HtmlTemplate\HtmlTemplate;
$template = new HtmlTemplate('./main-template/');
$template = new HtmlTemplate(['./main-template/', './extra-files/res/']);
$template = new HtmlTemplate('./main-template/');
$template->addPaths(['./path1', './path2']);
$template->setPaths(['./path1', './path2']);
var_dump($template->getPaths());
$template = new HtmlTemplate(%template-sources%, 'index');
// or 'form' instead of 'index', or '404', or '403' etc.
$template->addBlock('hello-world');
HtmlTemplate::setPageVarFromBlock(string $var, string $blockName);
// here is $var is the name if your placeholder within the layout
// and $blockName is %template-sources%/Res/Blocks/$blockName.tpl
// here is $value is a scalar value or object wich implements __toString method
// and $var is a name of your placeholder within the layout
setPageVar(string $var, $value): void;
// this method can be used if you need to place file's $path content in your layout
setPageVarFromFile(string $var, string $path): void;
// you can set multyple vars with one call
// here $vars is an assoc array
setPageVars(array $vars): void;
compile(): string
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.