Hi,
Thanks for the new release!
I'd like to report a regression introduced in the latest version: accessing an array item by key 0 (zero) no longer works. This was supported in version 0.9.x.
Reproduction case:
<?php
require_once '/var/www/html/app/vendor/autoload.php';
use DevTheorem\Handlebars\Handlebars;
use DevTheorem\Handlebars\Options;
$template = <<<HBS
Page title if key === 0: {{this.0.title}}
Page title if key === 1: {{this.1.title}}
Page title if key === 2: {{this.2.title}}
HBS;
$opts = new Options();
$compiled = Handlebars::precompile($template, $opts);
$renderer = Handlebars::template($compiled);
// Simulate the context that RenderHelper passes: the children array directly
$children = [
0 =>['title' => 'Page A', 'link' => '/a', 'lvl' => 1, 'active' => false, 'current' => false, 'children' => []],
1 =>['title' => 'Page B', 'link' => '/b', 'lvl' => 1, 'active' => true, 'current' => true, 'children' => []],
2 =>['title' => 'Page C', 'link' => '/c', 'lvl' => 1, 'active' => false, 'current' => false, 'children' => []],
];
$result = $renderer($children, []);
echo "=== RENDER OUTPUT ===\n";
echo $result;
echo "\n=== END OUTPUT ===\n";
Actual output:
=== RENDER OUTPUT ===
Page title if key === 0:
Page title if key === 1: Page B
Page title if key === 2: Page C
=== END OUTPUT ===
Expected output: {{this.0.title}} should resolve to Page A, consistent with the behavior of keys 1 and 2.
It appears that a zero-based key is being treated as falsy and skipped during lookup. Keys 1 and 2 resolve correctly.
Thanks for looking into this — and for all the work on the library!
Hi,
Thanks for the new release!
I'd like to report a regression introduced in the latest version: accessing an array item by key
0(zero) no longer works. This was supported in version 0.9.x.Reproduction case:
Actual output:
Expected output:
{{this.0.title}}should resolve toPage A, consistent with the behavior of keys1and2.It appears that a zero-based key is being treated as falsy and skipped during lookup. Keys
1and2resolve correctly.Thanks for looking into this — and for all the work on the library!