Skip to content

Handlebars View Parser package for the PHP Slim Framework

License

Notifications You must be signed in to change notification settings

NatLibFi/slim-handlebars

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Slim Handlebars

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).

How to Install

using Composer

Create a composer.json file in your project root:

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

Then run the following composer command:

$ 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:

$view = $app->view();
$view->parserOptions = array(
    'charset' => 'ISO-8859-1'
);

Templates (suffixed with .html) are assumed to be located within /templates. An optional sub-directory of partials (/templates/partials) can also be used.

To render the templates within your routes:

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

Authors

Jamie Cressey

License

MIT Public License

About

Handlebars View Parser package for the PHP Slim Framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%