merophp / php-template-view
PHP template view plugin for merophp/view-engine
0.1-beta
2022-08-15 12:41 UTC
Requires
- php: >=7.4
- merophp/view-engine: 0.1.*
- psr/link: ^1.1
Requires (Dev)
- phpunit/phpunit: ^9.5
README
Introduction
PHP template view plugin for merophp/view-engine.
(!) Be aware of security problems if you don't escape your variables in templates.
Installation
Via composer:
composer require merophp/php-template-view
Basic Usage
require_once 'vendor/autoload.php';
use Merophp\PhpTemplateViewPlugin\PhpTemplateView;
use Merophp\ViewEngine\ViewEngine;
use Merophp\ViewEngine\ViewPlugin\Collection\ViewPluginCollection;
use Merophp\ViewEngine\ViewPlugin\Provider\ViewPluginProvider;
use Merophp\ViewEngine\ViewPlugin\ViewPlugin;
use Merophp\ViewEngine\TemplateArgument\Argument;
use Merophp\ViewEngine\TemplateArgument\SharedArgument;
$collection = new ViewPluginCollection();
$collection->add(
new ViewPlugin(PhpTemplateView::class),
]);
$provider = new ViewPluginProvider($collection);
$viewEngine = new ViewEngine($provider);
$view = $viewEngine->initializeView();
$view->assignTemplateArguments(
new Argument('name', 'Tom'),
new SharedArgument('name', 'Tom') //This argument is available in the template and all of its partials
);
$view->template('viewPackage.hello');
echo $viewEngine->renderView($view);