Skip to content
Kirby 3 Component, Snippet and Page Method for semantic templates with Handlebars and Mustache
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
classes #7 Feb 17, 2019
vendor pluginkit Feb 6, 2019
.editorconfig pluginkit Feb 6, 2019
composer.json #7 Feb 17, 2019
composer.lock #7 Feb 17, 2019

Kirby 3 Handlebars

GitHub release License Kirby Version Kirby 3 Pluginkit

Kirby 3 Component, Snippet and Page Method for semantic templates with Handlebars and Mustache

Commercial Usage

This plugin is free but if you use it in a commercial project please consider to


  • unzip as folder site/plugins/kirby3-handlebars or
  • git submodule add site/plugins/kirby3-handlebars or
  • composer require bnomei/kirby3-handlebars



  • LightnCandy is extremely fast and lightweight.
  • Templates are only precompiled to native PHP on modification.
  • Render output is cached even without Kirbys Page Cache. The render cache is devalidated if either template or data is modified.

Usage without Component


Render unto {{ c }} the things that are {{ c }}'s, and unto {{ g }} the things that are {{ g }}'s.


{{ page.title }} of <i>{{ c }}</i>.


return function ($site, $page, $kirby) {
  return ['c'=>'Cassia', 'g'=>null];


  snippet('plugin-handlebars', [
    'template' => 'render-unto',
    'data' => [
        'c' => 'Caesar', 
        'g' => 'God'
  // => Render unto Caesar the things that are Caesar's, and unto God the things that are God's.

  // or
  echo $page->template();
  // => home

  echo $page->handlebars(); // template of page as string 'home', data from site/controllers/home.php
  // => Home of <i>Cassia</i>.
  echo $page->handlebars('render-unto', ['g'=>'Gods']); // template 'render-unto', data from site/controllers/home.php merged with custom array
  // => Render unto Cassia the things that are Cassia's, and unto God the things that are God's.

  hbs('render-unto', ['c' => 'Caesar', 'g' => 'God']);

TIP: you can also get the output in a variable setting snippets return-param to true. $output = snippet(..., [...], true);

Usage as Template Component

  • Put your handlebars templates in the site/templates/ folder.
  • See below on how turn on Component and configure File extension in settings.
  • Prepare data in Controllers stored at site/controllers/* which will be available in the templates
  • In case you do not have a handlebar template with matching name it will fallback to kirbys php template logic.



  • default: false if true all templating will be handled by this plugin.


  • default: true By default data sent to template will NOT be escaped. This way your templates can render data formated as html. You can use Kirbys Field Methods $field->kirbytext(), $field->html() or the Kirby\Toolkit\Str-Class functions to escape your text properly. Alternatively you can set it to false and use {{{ var }}} triple mustaches.


  • default: callback returning kirby()->roots()->templates()


  • default: callback returning kirby()->roots()->templates().'/partials'


  • default: hbs


  • default: lnc, hbs compiled to php


  • default: true, cache render based on hash of data


  • default: true, cache paths of template and partial files


  • default: true, cache compiled php


This plugin is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please create a new issue.



It is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.

You can’t perform that action at this time.