2017 © Pedro Peláez
 

library pug-view

Render PUG templates into a PSR-7 Response object.

image

bnf/pug-view

Render PUG templates into a PSR-7 Response object.

  • Monday, January 8, 2018
  • by bnf
  • Repository
  • 1 Watchers
  • 0 Stars
  • 21 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 5 % Grown

The README.md

Build Status, (*1)

PUG Renderer

This is a renderer for rendering PUG templates into a PSR-7 Response object. It works well with Slim Framework 3., (*2)

Installation

Install with Composer:, (*3)

composer require bnf/pug-view

Usage with Slim 3

use Bnf\PugView\PugRenderer;

include 'vendor/autoload.php';

$app = new Slim\App();
$container = $app->getContainer();

$settings = [
    'extension' => '.pug',
    'basedir' => 'templates/'
];

$container['view'] = function($c) {
    return new PugRenderer($settings);
};

/* PugRenderer is added as middleware to automatically inject the $response object. */
$app->add('view');

/* Add global template variables */
$app->add(function($request, $response, $next) {
    $this->view->set('title', 'default title');
    // Make the container accessible in the view, so that every object can be accessed in the template:
    // E.g: a(href=c.router.pathFor('named-route'))
    $this->view->set('c', $this);

    return $next($request, $response);
});

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

$app->run();

Usage with any PSR-7 Project

//Construct the View
$settings = [
    'extension' => '.pug',
    'basedir' => 'templates/'
];
$phpView = new PugRenderer($settings);

//Render a Template
$response = $phpView->render('template', $yourData, new Response());

The Versions

08/01 2018

dev-master

9999999-dev

Render PUG templates into a PSR-7 Response object.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework template renderer slim pug view

08/01 2018

2.0.0

2.0.0.0

Render PUG templates into a PSR-7 Response object.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework template renderer slim pug view

08/01 2018

v3.x-dev

3.9999999.9999999.9999999-dev

Render PUG templates into a PSR-7 Response object.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework template renderer slim pug view

22/04 2017

1.1.0

1.1.0.0

Render PUG templates into a PSR-7 Response object.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework template renderer slim pug view

22/04 2017

1.0.0

1.0.0.0

Render PUG templates into a PSR-7 Response object.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework template renderer slim pug view