Recommend this page to a friend! |
Download |
Info | Example | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
69% | Total: 183 | All time: 8,686 This week: 455 |
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 |
|
<?php |
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 (10) |
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 (10) | / | demo |
File | Role | Description | ||
---|---|---|---|---|
cache (1 file) | ||||
templates (2 files) | ||||
DemoView.php | Class | Class source | ||
index.php | Example | Example script |
Files (10) | / | demo | / | cache |
File | Role | Description |
---|---|---|
mask_426fd72e0d52b...3fbcd5766dbf527.php | Example | Example script |
Files (10) | / | demo | / | templates |
File | Role | Description |
---|---|---|
layout.html | Data | Auxiliary data |
partial.html | Data | Auxiliary data |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
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.