2017 © Pedro Peláez
 

library slim-handlebars

Handlebars View Parser package for the Slim Framework based on jayc89/slim-handlebars

image

radicaldrew/slim-handlebars

Handlebars View Parser package for the Slim Framework based on jayc89/slim-handlebars

  • Wednesday, March 25, 2015
  • by radicaldrew
  • Repository
  • 1 Watchers
  • 1 Stars
  • 29 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 2 Versions
  • 7 % Grown

The README.md

Slim Handlebars

Repository built from original jayc89/slim-handlebars, kudos to jayc89 thank you for the great start. There was a bunch of things I needed with Handlebars and Slim that was not possible to do without modifying the orginal code. I added and made sure you can use custom extensions. I also added the ability to add your own helpers using a addHelper method. This repository contains a custom View class for Handlebars (https://github.com/mardix/Handlebars). You can use the custom View class by either requiring the appropriate class in your Slim Framework bootstrap file and initialize your Slim application using an instance of the selected View class or using Composer (the recommended way)., (*1)

How to Install

using Composer

Create a composer.json file in your project root:, (*2)

{
    "require": {
        "radicaldrew/slim-handlebars": "dev-master"
    }
}

Then run the following composer command:, (*3)

$ php composer.phar install

How to use

<?php
require 'vendor/autoload.php';

$app = new \Slim\Slim(array(
    'view' => new \Slim\Handlebars\Handlebars()
));

To use Handlebars options do the following:, (*4)

$view = $app->view();
$view->setTemplatesDirectory('./views');
$view->parserOptions = array(
    'partialsDirectory' => './views/partials',
    'templateExtension' => 'html'
);

Templates (suffixed with .html in the example above) are assumed to be located within /templates. An optional sub-directory of partials (/templates/partials) can also be used., (*5)

To render the templates within your routes:, (*6)

$app->get('/', function () use ($app) {
    $array = array();
    $app->render("home", $array);
});

How to add Registered Helpers

$view = $app->view();
$view->addHelper("upper",function($template, $context, $args, $source){
                                return strtoupper($context->get($args));
                         });

Authors

Andrew Karp, (*7)

based on this original repistory Jamie Cressey, (*8)

License

MIT Public License, (*9)

The Versions

25/03 2015

dev-master

9999999-dev http://github.com/radicaldrew/slim-handlebars

Handlebars View Parser package for the Slim Framework based on jayc89/slim-handlebars

  Sources   Download

MIT

The Requires

 

templating extensions handlebars slimphp

19/01 2015

dev-php-5.3

dev-php-5.3 http://github.com/jayc89/Slim-Handlebars

Handlebars View Parser package for the Slim Framework

  Sources   Download

MIT

The Requires

 

templating extensions handlebars slimphp