jsangrador/phptal-view

This package is abandoned and no longer maintained. No replacement package was suggested.

Render PHPTAL view templates into a PSR-7 Response object.

3.0.0 2016-01-21 23:14 UTC

This package is not auto-updated.

Last update: 2020-10-21 00:58:41 UTC


README

Development of this fork has been moved to https://gitlab.com/jsangradorp/PHPTAL-View

PHPTAL Renderer

This is a renderer for rendering PHPTAL view scripts into a PSR-7 Response object. It works well with Slim Framework 3.

Installation

Install with Composer:

composer require jsangrador/PHPTAL-view

Usage With Slim 3

use Slim\Views\PhpTalRenderer;

include "vendor/autoload.php";

$app = new Slim\App();
$container = $app->getContainer();
$container['renderer'] = new PhpTalRenderer("./templates");

$app->get('/hello/{name}', function ($request, $response, $args) {
    return $this->renderer->render($response, "/hello.html", $args);
});

$app->run();

Usage with any PSR-7 Project

//Construct the View
$phpView = new PhpTalRenderer("./path/to/templates");

//Render a Template
$response = $phpView->render(new Response(), "/path/to/template.html", $yourData);

Exceptions

\RuntimeException - if template does not exist

\InvalidArgumentException - if $data contains 'template'