Skip to content

Commit

Permalink
add test for handlebars custom helper context change
Browse files Browse the repository at this point in the history
  • Loading branch information
Zordius Chen committed Jul 21, 2014
1 parent 928f550 commit d0c369b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/helpers_for_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,16 @@ function myif ($conditional, $options) {
}
}

function mywith ($context, $options) {
return $options['fn']($context);
}

function myeach ($context, $options) {
$ret = '';
foreach ($context as $cx) {
$ret .= $options['fn']($cx);
}
return $ret;
}

?>
9 changes: 9 additions & 0 deletions tests/regressionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,15 @@ public function issueProvider()
),
'expected' => 'NO',
),

Array(
'template' => '{{#mywith foo}}YA: {{name}}{{/mywith}}',
'data' => Array('name' => 'OK?', 'foo' => Array('name' => 'OK!')),
'options' => Array(
'hbhelpers' => Array('mywith'),
),
'expected' => 'YA: OK!',
),
);

return array_map(function($i) {
Expand Down

0 comments on commit d0c369b

Please sign in to comment.