Skip to content

Commit f9e7af4

Browse files
committed
fix(Handlebars): "or" helper returns first truthy value
1 parent 29f4d4f commit f9e7af4

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

include/mrdocs/Support/Handlebars.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ and_fn(dom::Array const& args);
11171117
* The "or" helper returns true if any of the values are truthy.
11181118
*/
11191119
MRDOCS_DECL
1120-
bool
1120+
dom::Value
11211121
or_fn(dom::Array const& args);
11221122

11231123
/** "eq" helper function

src/lib/Support/Handlebars.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3934,15 +3934,19 @@ and_fn(dom::Array const& args)
39343934
return true;
39353935
}
39363936

3937-
bool
3938-
or_fn(dom::Array const& args) {
3937+
dom::Value
3938+
or_fn(dom::Array const& args)
3939+
{
39393940
std::size_t const n = args.size();
3940-
if (n == 0) return false;
3941+
if (n == 0)
3942+
{
3943+
return false;
3944+
}
39413945
for (std::size_t i = 0; i < n - 1; ++i)
39423946
{
39433947
if (args.get(i))
39443948
{
3945-
return true;
3949+
return args.get(i);
39463950
}
39473951
}
39483952
return false;

0 commit comments

Comments
 (0)