Skip to content

Commit

Permalink
v2
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Meilick <[email protected]>
  • Loading branch information
bnomei committed Jan 8, 2019
1 parent bd2a6ea commit dc4c9cf
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 263 deletions.
13 changes: 9 additions & 4 deletions classes/Handlebars.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php

namespace Bnomei;

use LightnCandy\LightnCandy;
use Kirby\Toolkit\F;
use Kirby\Toolkit\Dir;

Expand Down Expand Up @@ -28,7 +32,7 @@ private static function compileOptions()
}

$flags = LightnCandy::FLAG_ELSE;
if (option('bnomei.handlebars.escape')) {
if (option('bnomei.handlebars.no-escape')) {
$flags |= LightnCandy::FLAG_NOESCAPE;
}
// NOTE: current will not notice change between debug and not. l'n'c debug is not supported here yet.
Expand Down Expand Up @@ -118,7 +122,9 @@ private static function templateOutput($filename, $isPartial = false)
if ($isPartial) {
$filename = '@' . $filename;
}
return kirby()->roots()->templates() . DIRECTORY_SEPARATOR . $filename . '.' .option('bnomei.handlebars.extension.output');
return kirby()->roots()->cache() . DIRECTORY_SEPARATOR .
'bnomei' . DIRECTORY_SEPARATOR . 'handlebars' . DIRECTORY_SEPARATOR . 'lnc' . DIRECTORY_SEPARATOR .
$filename . '.' .option('bnomei.handlebars.extension.output');
}

private static $templates = [];
Expand Down Expand Up @@ -195,7 +201,6 @@ public static function r($name, array $data = [], $root = null, $file = null): s
return '';
}


if (!$result || $loadTemplate['needsUpdate']) {
// NOTE: since LightnCandy returns a Closure and
// these can not be packed into a var as string
Expand All @@ -204,7 +209,7 @@ public static function r($name, array $data = [], $root = null, $file = null): s
$result = snippet('handlebars/render', [
'precompiledTemplate' => $php,
'data' => $data,
]);
], true);

if ($renderCacheId) {
$renderCache->set($renderCacheId, $result);
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@
],
"require": {
"php": ">=7.1.0",
"zordius/lightncandy": "1.2.2",
"getkirby/cms": "^3.0.0-RC-2.0"
"getkirby/cms": "^3.0.0-RC-2.0",
"zordius/lightncandy": "1.2.2"
},
"conflict": {
"getkirby/kirby": "<3.0"
},
"scripts": {
"zip": [
"touch kirby3-handlebars.zip",
"rm kirby3-handlebars.zip",
"composer install --no-dev",
"composer remove getkirby/cms",
Expand Down
Loading

0 comments on commit dc4c9cf

Please sign in to comment.