Skip to content

Commit 16cce03

Browse files
committed
Correctly parse handlebars after raw block
Fixes zordius/lightncandy#344
1 parent 5a4dfb8 commit 16cce03

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Validator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public static function verify(Context $context, string $template): void
3737
}
3838
static::pushToken($context, $V);
3939
}
40+
// set template to remainder after pushed token
4041
$template = "{$matches[Token::POS_RSPACE]}{$matches[Token::POS_ROTHER]}";
4142
}
4243
static::pushToken($context, $template);
@@ -473,8 +474,8 @@ protected static function rawblock(array &$token, Context $context): bool
473474
$context->error[] = 'Bad token ' . Token::toString($token) . ' ! Do you mean ' . Token::toString($token, [Token::POS_ENDRAW => '}}']) . ' ?';
474475
}
475476
if ($context->rawBlock) {
476-
Token::setDelimiter($context);
477477
$context->rawBlock = false;
478+
Token::setDelimiter($context);
478479
} else {
479480
if ($token[Token::POS_OP]) {
480481
$context->error[] = "Wrong raw block begin with " . Token::toString($token) . ' ! Remove "' . $token[Token::POS_OP] . '" to fix this issue.';

tests/RegressionTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,16 @@ public static function issueProvider(): array
13051305
'expected' => '#a(0)=b-321-123#c(1)=d-321-123#e(2)=f-321-123',
13061306
],
13071307

1308+
[
1309+
'id' => 344,
1310+
'template' => '{{{{raw}}}} {{bar}} {{{{/raw}}}} {{bar}}',
1311+
'data' => [
1312+
'raw' => true,
1313+
'bar' => 'content',
1314+
],
1315+
'expected' => ' {{bar}} content',
1316+
],
1317+
13081318
[
13091319
'id' => 357,
13101320
'template' => '{{echo (echo "foobar(moo).")}}',

0 commit comments

Comments
 (0)