Kirby 3 Plugin Handlebars


return function (Kirby\Cms\Site $site, Kirby\Cms\Page $page, Kirby\Cms\App $kirby) {
  return ['c'=>'Cassia', 'g'=>null];


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


/** @var Kirby\Cms\App $kirby */
/** @var Kirby\Cms\Site $site */
/** @var Kirby\Cms\Page $page */
?><!DOCTYPE html>
<html <?= site()->attrLang() ?>>

  <head><?php snippet('plugin-htmlhead') ?></head>

      $github = lapse(md5($page->id()), function() {
        $m = '';
        return [
          'templates/handlebars' => html(Kirby\Http\Remote::get($m.'templates/handlebars.php')->content()),
          'templates/render-unto' => html(Kirby\Http\Remote::get($m.'templates/render-unto.hbs')->content()),
          'controllers/handlebars' => html(Kirby\Http\Remote::get($m.'controllers/handlebars.php')->content()),
    }); ?>

    <h1><?= $page->title()->html() ?></h1>

    <pre><code data-language="php"><?= $github['controllers/handlebars'] ?></code></pre>

    <pre><code data-language="php"><?= $github['templates/render-unto'] ?></code></pre>

    <pre><code data-language="php"><?= $github['templates/handlebars'] ?></code></pre>

      // template 'render-unto'
      // data from site/controllers/home.php merged with custom array
      echo $page->handlebars('render-unto', ['g'=>'Gods']); ?>

    <h2>hbs helper</h2>
      <?php hbs('render-unto', ['c' => 'Caesar', 'g' => 'God']) ?>

    <?php snippet('footer') ?>


Render unto Cassia the things that are Cassia's, and unto Gods the things that are Gods's.

hbs helper

Render unto Caesar the things that are Caesar's, and unto God the things that are God's.