Skip to content

Commit e22564e

Browse files
committed
Fix parsing raw block helper params
1 parent 73a16ef commit e22564e

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

src/Validator.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ protected static function pushToken(Context $context, array|string $token)
8686
}
8787
if (is_string($token)) {
8888
static::pushPartial($context, $token);
89-
if (is_string(end($context->parsed[0]))) {
90-
$context->parsed[0][key($context->parsed[0])] .= $token;
91-
return;
92-
}
9389
} else {
9490
static::pushPartial($context, Token::toString($context->currentToken));
9591
switch ($context->currentToken[Token::POS_OP]) {
@@ -466,8 +462,6 @@ protected static function rawblock(array &$token, Context $context): bool
466462
return true;
467463
}
468464

469-
$token[Token::POS_INNERTAG] = $inner;
470-
471465
// Handle raw block
472466
if ($token[Token::POS_BEGINRAW] === '{{') {
473467
if ($token[Token::POS_ENDRAW] !== '}}') {
@@ -480,9 +474,10 @@ protected static function rawblock(array &$token, Context $context): bool
480474
if ($token[Token::POS_OP]) {
481475
$context->error[] = "Wrong raw block begin with " . Token::toString($token) . ' ! Remove "' . $token[Token::POS_OP] . '" to fix this issue.';
482476
}
483-
$context->rawBlock = $token[Token::POS_INNERTAG];
477+
// store name (before arguments) in order to find the block end
478+
$context->rawBlock = preg_split('/\s+/', $token[Token::POS_INNERTAG], 2)[0];
484479
Token::setDelimiter($context);
485-
$token[Token::POS_OP] = '#';
480+
$token[Token::POS_OP] = '#'; // parse as custom block
486481
}
487482
$token[Token::POS_ENDRAW] = '}}';
488483
}

tests/HandlebarsSpecTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@ public function testSpecs($spec)
133133
) ||
134134
$spec['description'] === 'strict - assume objects' ||
135135

136-
// helper for raw block
137-
($spec['it'] === 'helper for raw block gets parameters') ||
138-
139136
// lambda function in data
140137
$spec['it'] === 'pathed functions with context argument' ||
141138
$spec['it'] === 'Functions are bound to the context in knownHelpers only mode'

0 commit comments

Comments
 (0)