sinevia / php-library-template
PHP Library Template
v1.4.0
2019-02-17 20:29 UTC
This package is auto-updated.
Last update: 2024-10-16 19:39:59 UTC
README
Template is a simple, yet powerful templating engine in single file.
Features
- Single file. No external dependencies
- No new "language" to learn. Familiar PHP syntax.
- Default templates extension .phtml
Installation
Add the following to your composer file:
"require": { "sinevia/php-library-template": "1.*" },
Functionality
1) From File
\Sinevia\Template::fromFile($templateFilepath, $data = array());
2) From String
\Sinevia\Template::fromString($templateString, $data = array());
3) Cache
\Sinevia\Template::setCacheDirectory($cacheDirPath); \Sinevia\Template::setCache($key, $content, $options = array()); \Sinevia\Template::getCache($key, $options = array());
3) Helpers
\Sinevia\Template::minifyHtml($html); \Sinevia\Template::minifyCss($css); \Sinevia\Template::minifyJs($js);
Usage
$html = \Sinevia\Template::fromString($templateContent, [ 'page_meta_description' => $pageMetaDescription, 'page_meta_keywords' => $pageMetaKeywords, 'page_meta_robots' => $pageMetaRobots, 'page_canonical_url' => $pageCanonicalUrl, 'page_title' => $pageTitle, 'page_content' => $pageContent, ]);
\Sinevia\Template::setCache('key','content',array( 'post'=>true, 'get'=>true, 'session'=>true, 'expires'=>3600 // Default ));
Layout
- Template file:
[layout::public/guest/layout.phtml]
CONTENT
- Layout file:
<?php echo $content; ?>