ngyuki / ephp
ephp is php template
dev-master
2020-02-10 02:51 UTC
Requires
- php: ^7.2
- microsoft/tolerant-php-parser: ^0.0.18
Requires (Dev)
- mikey179/vfsstream: ^1.6
This package is auto-updated.
Last update: 2024-11-10 13:42:53 UTC
README
ephp is pure plain php template with support auto escape.
Example
<!-- index.phtml --> <strong><?= strtoupper($name) ?></strong>
Use StreamFilter
(for development).
<?php $filter = new StreamFilter(); (function ($filename, $variables) use ($filter) { extract($variables, EXTR_SKIP); require $filter->path($filename); //=> <strong>A & B</strong> })('index.phtml', ['name' => 'a & b']);
Use Compiler
(for production).
<?php $sourceDir = __DIR__; $compiledDir = __DIR__ . '/compiled'; $compiler = new Compiler($sourceDir, $compiledDir); (function ($filename, $variables) use ($compiler) { extract($variables, EXTR_SKIP); require $compiler->compile($filename); //=> <strong>A & B</strong> })('index.phtml', ['name' => 'a & b']);