Skip to content

Commit 5775c09

Browse files
committed
simplify readme example
1 parent 0b650ea commit 5775c09

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

README.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,13 @@ $template = Handlebars::compile('{{#equals my_var false}}Equal to false{{else}}N
104104
$options = [
105105
'helpers' => [
106106
'equals' => function (mixed $a, mixed $b, HelperOptions $options) {
107-
$jsEquals = function (mixed $a, mixed $b): bool {
108-
if ($a === null || $b === null || is_string($a) && is_string($b)) {
109-
// In JS, null is not equal to blank string or false or zero,
110-
// and when both operands are strings no coercion is performed.
111-
return $a === $b;
112-
}
113-
114-
return $a == $b;
115-
};
116-
117-
return $jsEquals($a, $b) ? $options->fn() : $options->inverse();
107+
// In JS, null is not equal to blank string or false or zero,
108+
// and when both operands are strings no coercion is performed.
109+
$equal = ($a === null || $b === null || is_string($a) && is_string($b))
110+
? $a === $b
111+
: $a == $b;
112+
113+
return $equal ? $options->fn() : $options->inverse();
118114
},
119115
],
120116
];

0 commit comments

Comments
 (0)