PHPackages                             voodoophp/handlebars - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. voodoophp/handlebars

ActiveLibrary[Templating &amp; Views](/categories/templating)

voodoophp/handlebars
====================

Handlebars processor for php

2.2.2(12y ago)31160.7k↑72.6%9[4 PRs](https://github.com/mardix/Handlebars/pulls)2MITPHPPHP &gt;=5.4.0

Since Nov 19Pushed 6y ago3 watchersCompare

[ Source](https://github.com/mardix/Handlebars)[ Packagist](https://packagist.org/packages/voodoophp/handlebars)[ Docs](http://voodoophp.org/docs/handlebars)[ RSS](/packages/voodoophp-handlebars/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (10)Used By (2)

[![Build Status](https://camo.githubusercontent.com/2883b209e5b61bd192dedd7f703770c120de193244020c4c6329d4c1411e562c/68747470733a2f2f7472617669732d63692e6f72672f6d61726469782f48616e646c65626172732e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/mardix/Handlebars)

---

\#Handlebars

---

#### A simple, logic-less, yet powerful templating engine for PHP

[](#a-simple-logic-less-yet-powerful-templating-engine-for-php)

---

Name: **Handlebars**

License: MIT

Version : 2.2.x

Requirements: PHP &gt;= 5.4

---

About Handlebars
----------------

[](#about-handlebars)

Handlebars provides the power necessary to let you build semantic templates effectively with no frustration, that keep the view and the code separated like we all know they should be.

Fork of: [Handlebars.php by XaminProject](https://github.com/XaminProject/handlebars.php)

Handlebars, is the PHP port of [Handlebars.js](http://handlebarsjs.com/)

Extended docs can be found at [VoodooPHP.org/docs/handlebars](http://voodoophp.org/docs/handlebars)

---

Install Handlebars
------------------

[](#install-handlebars)

You can just download Handlebars.php as is, or with Composer.

To install with composer, add the following in the require key in your **composer.json** file

```
"voodoophp/handlebars": "2.*"

```

composer.json

```
{
    "name": "myapp/name",
    "description": "My awesome app name",
    "require": {
        "voodoophp/handlebars": "2.*"
    }
}

```

---

Getting Started
---------------

[](#getting-started)

At the minimum, we are required to have an array model and a template string. Alternatively we can have a file containing handlebars (or html, text, etc) expression.

#### Template

[](#template)

Handlebars templates look like regular HTML, with embedded handlebars expressions.

Handlebars HTML-escapes values returned by a {{expression}}.

```

	  {{title}}

	    Hello, my name is {{name}}

```

The string above can be used as is in your PHP file, or be put in a file (ie: */templates/main.tpl*), to be called upon rendering.

#### PHP file

[](#php-file)

Now the we've created our template file, in a php file (index.php) we'll create the data to passed to the model. The model is a key/value array.

Below we are going to create the Handlebars object, set the partials loader, and put some data in the model.

**/index.php**

```
