2017 © Pedro Peláez
 

library slim-plates-view

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

image

kadevland/slim-plates-view

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

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

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., (*1)

Install

Via Composer, (*2)

$ composer require kadevland/slim-plates-view

Requires Slim Framework 3 and PHP 5.5.0 or newer., (*3)

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

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:, (*4)

<h1>User List</h1>
<ul>
    <li><a href="<?= $this->path_for('profile', { 'name': 'josh' }) ?>">Josh</a></li>
</ul>

This component propose a feature is_url() function to your Plates templates. You can use this function to check if URL match witch Request URL/Path. This is an example Plates template:, (*5)

<h1>Categories List</h1>
<ul>
---
$link=path_for('categorie', { 'slug': 'my-categorie' });
    <li class="<?=$this->is_url($link)?'active':''?>"><a href="<?=$link?>">My categorie</a></li>
---
</ul>

Testing

phpunit

Contributing

Please see CONTRIBUTING for details., (*6)

License

The MIT License (MIT). Please see License File for more information., (*7)

The Versions

16/10 2016

dev-master

9999999-dev https://github.com/kadevland/slim-plates-view

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

  Sources   Download

MIT

The Requires

 

The Development Requires

framework template slim view plates

16/10 2016

1.1

1.1.0.0 https://github.com/kadevland/slim-plates-view

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

  Sources   Download

MIT

The Requires

 

The Development Requires

framework template slim view plates

05/10 2016

v1.0

1.0.0.0 https://github.com/kadevland/slim-plates-view

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

  Sources   Download

MIT

The Requires

 

The Development Requires

framework template slim view plates