PHPackages                             kadevland/slim-plates-view - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. kadevland/slim-plates-view

AbandonedArchivedLibrary[Framework](/categories/framework)

kadevland/slim-plates-view
==========================

Slim Framework 3 view helper built on top of the Plates templating component

1.1(9y ago)025MITPHPPHP &gt;=5.5.0

Since Oct 5Pushed 9y ago1 watchersCompare

[ Source](https://github.com/kadevland/slim-plates-view)[ Packagist](https://packagist.org/packages/kadevland/slim-plates-view)[ Docs](https://github.com/kadevland/slim-plates-view)[ RSS](/packages/kadevland-slim-plates-view/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (3)Versions (3)Used By (0)

Slim Framework Plates View
==========================

[](#slim-framework-plates-view)

This is a Slim Framework view helper built on top of the Plates templating component. You can use this component to create and render templates in your Slim Framework application.

Install
-------

[](#install)

Via [Composer](https://getcomposer.org/)

```
$ composer require kadevland/slim-plates-view
```

Requires Slim Framework 3 and PHP 5.5.0 or newer.

Usage
-----

[](#usage)

```
// Create Slim app
$app = new \Slim\App();

// Fetch DI Container
$container = $app->getContainer();

// Register Plates View helper
$container['view'] = function ($c) {
    $view = new \Kadevland\Slim\Plates\View\PlatesView('path/to/templates','extention');

    // Instantiate and add Slim specific extension
    $basePath = rtrim(str_ireplace('index.php', '', $c['request']->getUri()->getBasePath()), '/');
    $view->addExtension(new \Kadevland\Slim-Plates-View\PlatesViewExtension($c['router'], $basePath));

    return $view;
};

// Define named route
$app->get('/hello/{name}', function ($request, $response, $args) {
    return $this->view->render($response, 'profile.html', [
        'name' => $args['name']
    ]);
})->setName('profile');

// Run app
$app->run();
```

Custom template functions
-------------------------

[](#custom-template-functions)

This component exposes a custom `path_for()` function to your Plates templates. You can use this function to generate complete URLs to any Slim application named route. This is an example Plates template:

```
User List
