jayc89 / slim-handlebars
Handlebars View Parser package for the Slim Framework
Requires
- php: >=5.4.0
- slim/slim: >=2.4.0
- xamin/handlebars.php: 0.10.0
Suggests
- justblackbird/handlebars.php-helpers: A set of helpers for Handlebars.php template engine.
This package is not auto-updated.
Last update: 2024-11-05 03:18:55 UTC
README
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 .handlebars) are assumed to be located within Slim's template directory (<doc root>/templates, by default). Partials are picked up from <template directory>/partials.
Constructor takes an array as a parameter. The following properties are supported:
- partialsDirectory
- templateExtensions
To render the templates within your routes:
$app->get('/', function () use ($app) { $array = array(); $app->render("home", $array); });
Authors
License
MIT Public License