ngyuki/ephp

ephp is php template

dev-master 2020-02-10 02:51 UTC

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 &amp; 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 &amp; B</strong>
})('index.phtml', ['name' => 'a & b']);