PHPackages                             iantsch/wp-hbs-engine - 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. iantsch/wp-hbs-engine

ActiveWordpress-plugin[Templating &amp; Views](/categories/templating)

iantsch/wp-hbs-engine
=====================

Renders Handlebars templates within your WordPress Theme/Plugin

0.0.1(8y ago)4355[1 issues](https://github.com/iantsch/wp-hbs-engine/issues)MITPHP

Since Feb 23Pushed 6y ago1 watchersCompare

[ Source](https://github.com/iantsch/wp-hbs-engine)[ Packagist](https://packagist.org/packages/iantsch/wp-hbs-engine)[ RSS](/packages/iantsch-wp-hbs-engine/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

WordPress Handlebars Engine
===========================

[](#wordpress-handlebars-engine)

![licence](https://camo.githubusercontent.com/7982dd5e36dbafbf6707da94ff0331fef95b911ae76f0562835bf5d6042d47fc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e63652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265) ![tag](https://camo.githubusercontent.com/0065b0684cf57e7e4a023d2ce652b08bb6c74e393cd5dcf35783a4f07dc1c448/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7461672d76302e302e312d6c69676874677265792e7376673f7374796c653d666c61742d737175617265)

Renders Handlebars/Moustache templates within your WordPress Theme/Plugin. Handlebars rendering is powered by [LightnCandy](https://github.com/zordius/lightncandy). Tested with WordPress 5.2.3

Installation
------------

[](#installation)

You can install this (must-use) plugin two ways

### Via Composer

[](#via-composer)

If you load your dependenies via Composer you can load this plugin with

```
$ php composer require iantsch/wp-hbs-engine
```

### Via Download

[](#via-download)

Download/fork this repository and copy the plugin-folder into `wp-content/plugins/`. If you visit your Plugin section in the `wp-admin` area, activate it and you are good to go.

### Troubleshoots

[](#troubleshoots)

You need to load the `zordius/lightncandy` dependency via composer. Install composer and run `$ composer install` in the `wp-content/plugins/wp-hbs-engine` folder.

The plugin needs a folder with write permissions for caching the handlebar files. It tries to create the folder `wp-content/plugins/wp-hbs-engine/cache`.

The plugin will try to load partials from the default folder `src/templates/partials` within your current theme. If the folder does not exist please add it (or use the filter hook to adapt).

Usage
-----

[](#usage)

Setup and modify the render engine to your needs in your `functions.php` or your plugin

```
add_filter('MBT/Engine/Handlebars/Helpers', function($helpers) {
  $helpers['__'] = function($string) {
    return __($string, 'mbt');
  };
  $helpers['permalink'] = 'get_permalink';
  $helpers['content'] = function() {
    return apply_filters('the_content', get_the_content());
  };
  return $helpers;
});
```

In your theme call it like a WordPress function.

```
global $post;
while (have_posts()){
  the_post();
  $data = (array) $post;
  the_hbs_template('article', $data);
}
```

In your `article.hbs` it is [handlebarsjs.com](https://handlebarsjs.com) syntax

```
{{this.post_title}}
{{{content}}}
{{__ 'Click'}}
```

API
---

[](#api)

#### get\_hbs\_template

[](#get_hbs_template)

ParameterTypeDescription`$template`stringtemplate name`$data`stringassociative array with all the needed data for the template`$templateDir`string | booleanabsolutee path to template entry directory, defaults to `/src/templates/` in current theme`$cacheDir`string | booleanabsolute path to caching directory, defaults to `/cache/` in plugins folder*Returns*: `$html` - the rendered HTML output#### the\_hbs\_template

[](#the_hbs_template)

ParameterTypeDescription`$template`stringtemplate name`$data`stringassociative array with all the needed data for the template`$templateDir`string | booleanabsolutee path to template entry directory, defaults to `/src/templates/` in current theme`$cacheDir`string | booleanabsolute path to caching directory, defaults to `/cache/` in plugins folderechoes the rendered HTML outputHooks
-----

[](#hooks)

There are several hooks to modify and adapt the render engine

### Filters

[](#filters)

#### MBT/Engine/Handlebars/Extension

[](#mbtenginehandlebarsextension)

ParameterTypeDescription`$extension`stringfile extension, default: `hbs`*Returns*: `$extension` - file extension of your handlebar templates#### MBT/Engine/Handlebars/Helpers

[](#mbtenginehandlebarshelpers)

ParameterTypeDescription`$helpers`arrayassociative array with callback functions for the implemented helpers`$this`objectCurrent instance of Handlebars engine*Returns*: `$helpers` - array of handlebars helper#### MBT/Engine/Handlebars/Flags

[](#mbtenginehandlebarsflags)

ParameterTypeDescription`$flags`intbitwise flags used by LightnCandy`$this`objectCurrent instance of Handlebars engine*Returns*: `$flags` - LightnCandy Flags#### MBT/Engine/Handlebars/Partials

[](#mbtenginehandlebarspartials)

ParameterTypeDescription`$partials`arrayassociative array with the relative path to the partials`$this`objectCurrent instance of Handlebars engine*Returns*: `$partials` - array of available partials#### MBT/Engine/Handlebars/DefaultData

[](#mbtenginehandlebarsdefaultdata)

ParameterTypeDescription`$defaultData`arrayfallback data for the template`$template`stringtemplate name*Returns*: `$defaultData` - fallback data for the template#### MBT/Engine/Handlebars/Data

[](#mbtenginehandlebarsdata)

ParameterTypeDescription`$data`arrayassociative array with all the needed data for the template`$template`stringtemplate name*Returns*: `$data` - the data for the template#### MBT/Engine/Handlebars/Html

[](#mbtenginehandlebarshtml)

ParameterTypeDescription`$html`stringrendered HTML output (with data)`$template`stringtemplate name`$data`arraydata used to render output*Returns*: `$html` - the rendered HTML output### Actions

[](#actions)

#### MBT/Engine/Handlebars/Init

[](#mbtenginehandlebarsinit)

ParameterTypeDescription`$this`objectCurrent instance of Handlebars engineCredits
-------

[](#credits)

[@iantsch](https://twitter.com/iantsch) - [web developer](https://mbt.wien) behind this and other projects.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3002d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/49e94c3b17e381fbdc139257000ad944d117dec0eb6d765879d8e1bcd40f7b1f?d=identicon)[iantsch](/maintainers/iantsch)

---

Top Contributors

[![iantsch](https://avatars.githubusercontent.com/u/22318501?v=4)](https://github.com/iantsch "iantsch (3 commits)")

---

Tags

handlebarslightncandywordpresswordpress-pluginwordpresspluginshandlebarslightncandy

### Embed Badge

![Health badge](/badges/iantsch-wp-hbs-engine/health.svg)

```
[![Health](https://phpackages.com/badges/iantsch-wp-hbs-engine/health.svg)](https://phpackages.com/packages/iantsch-wp-hbs-engine)
```

###  Alternatives

[proai/laravel-handlebars

A Laravel wrapper for LightnCandy for using the Handlebars (and Mustache) template engine.

38204.7k](/packages/proai-laravel-handlebars)[htmlburger/wpemerge-theme

A modern WordPress starter theme which uses the WP Emerge framework

2873.8k](/packages/htmlburger-wpemerge-theme)[benjaminmedia/wp-polylang-theme-strings

Polylang Theme Strings with support for Blade syntax

159.9k](/packages/benjaminmedia-wp-polylang-theme-strings)[frozzare/digster

Twig templates for WordPress

107.1k](/packages/frozzare-digster)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
