Skip to content

Commit

Permalink
feat(Handlebars): options data provide root context
Browse files Browse the repository at this point in the history
  • Loading branch information
alandefreitas committed Nov 25, 2024
1 parent fb7d6b9 commit e545dfe
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions src/lib/Support/Handlebars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1880,6 +1880,15 @@ evalExpr(
dom::Object cb = dom::newObject<HbsHelperObjectImpl>();
cb.set("name", helper);
cb.set("context", context);
dom::Object data;
if (!state.context.empty())
{
data = createFrame(state.context);
}
data.set("root", state.rootContext);
cb.set("data", data);
cb.set("root", state.rootContext);
cb.set("log", logger_);
setupArgs(all, context, state, args, cb, opt);
return Res{fn.call(args).value(), true, false, true};
MRDOCS_UNREACHABLE();
Expand Down Expand Up @@ -2414,7 +2423,13 @@ renderExpression(
dom::Object cb = dom::newObject<HbsHelperObjectImpl>();
cb.set("name", tag.helper);
cb.set("context", context);
cb.set("data", state.context);
dom::Object data;
if (!state.context.empty())
{
data = createFrame(state.context);
}
data.set("root", state.rootContext);
cb.set("data", data);
cb.set("log", logger_);
HandlebarsOptions noStrict = opt;
noStrict.strict = false;
Expand Down Expand Up @@ -2449,7 +2464,13 @@ renderExpression(
dom::Object cb = dom::newObject<HbsHelperObjectImpl>();
cb.set("name", helper_expr);
cb.set("context", context);
cb.set("data", state.context);
dom::Object data;
if (!state.context.empty())
{
data = createFrame(state.context);
}
data.set("root", state.rootContext);
cb.set("data", data);
cb.set("log", logger_);
HandlebarsOptions noStrict = opt;
noStrict.strict = false;
Expand Down Expand Up @@ -2487,7 +2508,13 @@ renderExpression(
dom::Object cb = dom::newObject<HbsHelperObjectImpl>();
cb.set("name", helper_expr);
cb.set("context", context);
cb.set("data", state.context);
dom::Object data;
if (!state.context.empty())
{
data = createFrame(state.context);
}
data.set("root", state.rootContext);
cb.set("data", data);
cb.set("log", logger_);
HandlebarsOptions noStrict = opt;
noStrict.strict = false;
Expand Down Expand Up @@ -3071,7 +3098,13 @@ renderBlock(
dom::Object cb = dom::newObject<HbsHelperObjectImpl>();
cb.set("name", tag.helper);
cb.set("context", context);
cb.set("data", state.context);
dom::Object data;
if (!state.context.empty())
{
data = createFrame(state.context);
}
data.set("root", state.rootContext);
cb.set("data", data);
cb.set("log", logger_);
HandlebarsOptions noStrict = opt;
noStrict.strict = opt.strict && emulateMustache;
Expand Down

0 comments on commit e545dfe

Please # to comment.