Recommend this page to a friend! |
Download .zip |
Info | Example | View files (10) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2022-10-21 (1 month ago) | 69% | Total: 181 This week: 1 | All time: 8,624 This week: 491 |
Version | License | PHP version | Categories | |||
mask 1.0.2 | MIT/X Consortium ... | 5 | PHP 5, Templates, Traits |
Description | Author | ||||||||||||||
This class provides a trait to process templates with class functions. Innovation Award |
|
Mask is a PHP trait that functions as a basic PHP template engine
__create a simple view to hold ALL view logic__
class MyView
{
protected $title = 'Hello';
protected function logic()
{
return 'World!';
}
}
__add mask__
use Taviroquai\Mask\Mask;
class MyView
{
use Mask;
protected $title = 'Hello';
protected function logic()
{
return 'World!';
}
}
__now create an HTML file: template.html__
<p>
{{ title }}
{{ if logic }}{{ logic }}{{ endif }}
</p>
__finally use it in PHP as__
$view = new MyView;
echo $view->mask('template');
__output:__
<p>
Hello
World!
</p>
{{ variableName }} {{ methodName }}
{{ if methodOrVariableName }} ... something ... {{ endif }}
{{ for variable as local }}
{{ local }}
{{ endfor }}
__include partial.html__ {{ include partial }}
// Set cache path
Mask::$templateCachePath = './path/to/cache';
// Set templates path
Mask::$templatePath = './path/to/templates';
// Choose what properties to publish by overriding getMaskData()
class MyView
{
use Mask;
protected $property1;
protected $property2;
public function getMaskData()
{
return array(
'property2' => 'override'
);
}
}
Files |
File | Role | Description | ||
---|---|---|---|---|
demo (2 files, 2 directories) | ||||
src (1 directory) | ||||
composer.json | Data | Auxiliary data | ||
composer.lock | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
README.md | Doc. | Documentation |
Files | / | demo |
File | Role | Description | ||
---|---|---|---|---|
cache (1 file) | ||||
templates (2 files) | ||||
DemoView.php | Class | Class source | ||
index.php | Example | Example script |
Files | / | demo | / | cache |
File | Role | Description |
---|---|---|
mask_426fd72e0d52b...3fbcd5766dbf527.php | Example | Example script |
Files | / | demo | / | templates |
File | Role | Description |
---|---|---|
layout.html | Data | Auxiliary data |
partial.html | Data | Auxiliary data |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
User Ratings | ||||||||||||||||||||||||||||||
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.