Download the PHP package gigglebox/dispatch-handlebars without Composer
On this page you can find all versions of the php package gigglebox/dispatch-handlebars. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gigglebox/dispatch-handlebars
More information about gigglebox/dispatch-handlebars
Files in gigglebox/dispatch-handlebars
Package dispatch-handlebars
Short Description handlebars support for dispatch micro framework
License MIT
Homepage https://github.com/GiggleboxStudios/dispatch-handlebars
Informations about the package dispatch-handlebars
{{handlebars}} for Dispatch
An extension for the Dispatch PHP micro-framework that provides support for Handlebars templates.
Requires:
Installation
This repo assumes you know how to install dependencies via Composer
composer.json:
Open a new terminal to your working directory and composer install or composer update.
Configuration
your-main-app-file.php
NOTE: If you do not define
handlebars.layoutandhandlebars.views, handlebars will use the defaultdispatch.layoutanddispatch.viewsvalues instead.
Using Handlebars with Dispatch
layout.handlebars:
homepage.handlebars:
In our example index.php file, we'll use the handlebars() function to render our template within our route:
index.php
The handlebars() function accepts three arguments:
The resulting HTML from our demo above renders something like this:
Extending Handlebars with Helpers
To define helpers for Handlebars, you need to define the functions you wish to use and pass them into the handlebars.helpers array as defined above.
example:
In handlebars.helpers, the key is the tag name that gets used in your handlebars templates, and the value is the name of the callback function we want to use when that helper is defined.
Read more about defining helpers at mardix/Handlebars
Credits
This package was written by Brandtley McMinn and is largely based on the Dispatch-Mustache package written by Jesus A. Domingo as an add-on for the Dispatch PHP micro-framework.
It depends on the Handlebars PHP library by fzerorubigd and Behrooz Shabani aka everplays.
LICENSE
All versions of dispatch-handlebars with dependencies
dispatch/dispatch Version >= 2.6.2
xamin/handlebars.php Version dev-master