File tree 2 files changed +44
-0
lines changed
2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -1044,6 +1044,17 @@ MRDOCS_DECL
1044
1044
void
1045
1045
registerAntoraHelpers (Handlebars& hbs);
1046
1046
1047
+ /* * Register logical helpers into a Handlebars instance
1048
+
1049
+ This function registers a number of common helpers that perform
1050
+ logical operations.
1051
+
1052
+ @param hbs The Handlebars instance to register the helpers into
1053
+ */
1054
+ MRDOCS_DECL
1055
+ void
1056
+ registerLogicalHelpers (Handlebars& hbs);
1057
+
1047
1058
/* * Register string helpers into a Handlebars instance
1048
1059
1049
1060
This function registers a number of common helpers that operate on
@@ -1130,6 +1141,18 @@ MRDOCS_DECL
1130
1141
bool
1131
1142
not_fn (dom::Array const & arg);
1132
1143
1144
+ /* * "select" helper function
1145
+ *
1146
+ * The "select" helper returns the second argument if the first argument is
1147
+ * truthy, and the third argument otherwise.
1148
+ */
1149
+ MRDOCS_DECL
1150
+ dom::Value
1151
+ select_fn (
1152
+ dom::Value condition,
1153
+ dom::Value result_true,
1154
+ dom::Value result_false);
1155
+
1133
1156
/* * "increment" helper function
1134
1157
*
1135
1158
* The "increment" helper adds 1 to the value if it's an integer and converts
Original file line number Diff line number Diff line change @@ -3674,6 +3674,17 @@ registerAntoraHelpers(Handlebars& hbs)
3674
3674
hbs.registerHelper (" year" , dom::makeInvocable (year_fn));
3675
3675
}
3676
3676
3677
+ void
3678
+ registerLogicalHelpers (Handlebars& hbs)
3679
+ {
3680
+ hbs.registerHelper (" and" , dom::makeVariadicInvocable (and_fn));
3681
+ hbs.registerHelper (" eq" , dom::makeVariadicInvocable (eq_fn));
3682
+ hbs.registerHelper (" ne" , dom::makeVariadicInvocable (ne_fn));
3683
+ hbs.registerHelper (" not" , dom::makeVariadicInvocable (not_fn));
3684
+ hbs.registerHelper (" or" , dom::makeVariadicInvocable (or_fn));
3685
+ hbs.registerHelper (" select" , dom::makeInvocable (select_fn));
3686
+ }
3687
+
3677
3688
bool
3678
3689
and_fn (dom::Array const & args)
3679
3690
{
@@ -3749,6 +3760,16 @@ increment_fn(dom::Value const& value)
3749
3760
return 1 ;
3750
3761
}
3751
3762
3763
+ dom::Value
3764
+ select_fn (
3765
+ dom::Value condition,
3766
+ dom::Value result_true,
3767
+ dom::Value result_false)
3768
+ {
3769
+ return isEmpty (condition) ?
3770
+ result_false : result_true;
3771
+ }
3772
+
3752
3773
dom::Value
3753
3774
detag_fn (dom::Value html)
3754
3775
{
You can’t perform that action at this time.
0 commit comments