Skip to content

Commit bd9098d

Browse files
committed
Fix rendering data in {{else}} of {{#each}}
zordius/lightncandy#369
1 parent 559847b commit bd9098d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Runtime.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ public static function sec($cx, $v, $bp, $in, $each, $cb, $else = null)
397397
}
398398
if ($each) {
399399
if ($else !== null) {
400-
$ret = $else($cx, $v);
400+
$ret = $else($cx, $in);
401401
return $ret;
402402
}
403403
return '';

tests/regressionTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,13 @@ public static function issueProvider()
13131313
'expected' => '#a(0)=b-321-123#c(1)=d-321-123#e(2)=f-321-123'
13141314
),
13151315

1316+
array(
1317+
'id' => 369,
1318+
'template' => '{{#each paragraphs}}<p>{{this}}</p>{{else}}<p class="empty">{{foo}}</p>{{/each}}',
1319+
'data' => array('foo' => 'bar'),
1320+
'expected' => '<p class="empty">bar</p>'
1321+
),
1322+
13161323
array(
13171324
'template' => '{{#each . as |v k|}}#{{k}}{{/each}}',
13181325
'data' => array('a' => array(), 'c' => array()),

0 commit comments

Comments
 (0)