2017 © Pedro Peláez
 

library slim-plates

Render your Slim 3 application views using Plates template engine.

image

projek-xyz/slim-plates

Render your Slim 3 application views using Plates template engine.

  • Thursday, October 13, 2016
  • by feryardiant
  • Repository
  • 6 Watchers
  • 21 Stars
  • 5,658 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 10 Versions
  • 7 % Grown

The README.md

Version Lisence Actions Status Coveralls Code Climate Maintainability SymfonyInsight Grade, (*1)

Plates Template Integration for Slim micro framework 3

Render your Slim 3 application views using Plates template engine., (*2)

Install

Via Composer, (*3)

$ composer require projek-xyz/slim-plates --prefer-dist

Requires Slim micro framework 3 and PHP 5.5.0 or newer., (*4)

Usage

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

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

// Register Plates View helper:
// Option 1, using PlatesProvider
$container->register(new \Projek\Slim\PlatesProvider);

// Option 2, using Closure
$container['view'] = function ($c) {
    $view = new \Projek\Slim\Plates([
        // Path to view directory (default: null)
        'directory' => 'path/to/views',
        // Path to asset directory (default: null)
        'assetPath' => 'path/to/static/assets',
        // Template extension (default: 'php')
        'fileExtension' => 'tpl',
        // Template extension (default: false) see: http://platesphp.com/extensions/asset/
        'timestampInFilename' => false,
    ]);

    // Set \Psr\Http\Message\ResponseInterface object
    // Or you can optionaly pass `$c->get('response')` in `__construct` second parameter
    $view->setResponse($c->get('response'));

    // Instantiate and add Slim specific extension
    $view->loadExtension(new Projek\Slim\PlatesExtension(
        $c->get('router'),
        $c->get('request')->getUri()
    ));

    return $view;
};

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

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

NOTE: * If you are using option 1 please make sure you already have $container['settings']['view'] in your configuration file. * Plates::setResponse() is required to use Plates::render() otherwise \LogicException will thrown., (*5)

Custom functions

This component exposes some Slim functions to your Plates templates., (*6)

pathFor()

You can use this function to generate complete URLs to any Slim application named route. Example:, (*7)

layout('base-template') ?>

start('body') ?>


Hallo =$this->e($name)?>

<small>=$this->pathFor('profile', ['name'=> $name])?></small> stop() ?>

Retrieve the base url of your Slim application. Example:, (*8)

<a href="<?=$this->baseUrl()?>">Some Link</a>

Or you can pass a permalink, (*9)

<a href="<?=$this->baseUrl('some/path')?>">Some Other Link</a>

basePath()

Retrieve the base url of your Slim application. Example:, (*10)

<link rel="stylesheet" href="<?=$this->basePath().'asset/css/main.css'?>">

uriFull()

Retrieve full request URI., (*11)

uriScheme()

Retrieve the scheme component of the URI., (*12)

uriHost()

Retrieve the host component of the URI, (*13)

uriPort()

Retrieve the port component of the URI., (*14)

uriPath()

Retrieve the path component of the URI., (*15)

uriQuery()

Retrieve the query string component of the URI., (*16)

uriFragment()

Retrieve the fragment component of the URI., (*17)

Contributing

Please see CONTRIBUTING and CONDUCT for details., (*18)

License

This library is open-sourced software licensed under MIT license., (*19)

The Versions

13/10 2016

dev-master

9999999-dev http://www.projek.xyz/slim-plates

Render your Slim 3 application views using Plates template engine.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework template library slim microframework view plates

10/10 2016

v0.2.2

0.2.2.0 http://www.projek.xyz/slim-plates

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

25/01 2016

v0.2.1

0.2.1.0 http://www.projek.xyz/slim-plates

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

20/12 2015

v0.2.0

0.2.0.0 http://www.projek.xyz/slim-plates

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

07/12 2015

v0.1.5

0.1.5.0 http://www.projek.xyz/slim-plates

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

07/11 2015

v0.1.4

0.1.4.0 http://www.projek.xyz/slim-plates

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

06/11 2015

v0.1.3

0.1.3.0 http://www.projek.xyz/slim-plates

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/11 2015

v0.1.2

0.1.2.0 http://www.projek.xyz/slim-plates

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

10/09 2015

v0.1.1

0.1.1.0 http://feryardiant.me/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

09/09 2015

v0.1.0

0.1.0.0 http://feryardiant.me/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