Recommend this page to a friend! |
![]() ![]() |
Info | ![]() |
![]() |
![]() ![]() |
Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2022-10-21 (1 month ago) ![]() | ![]() ![]() ![]() ![]() | 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'
);
}
}
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
||||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Lic. | License text | ||
![]() ![]() |
Doc. | Documentation |
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.