mrdocs::Handlebars::registerHelper

Register a helper accessible by any template in the environment.

Synopsis

Declared in <mrdocs/Support/Handlebars.hpp>

void
registerHelper(
    std::string_view name,
    dom::Function const& helper);

Description

The helper type is a type erased function of type dom::Function, which receives the resolved template arguments as parameters as a dom::Value for each parameter.

The helper function also receives an object populated with variables that are accessible in the current context as its N+1‐th parameter. This object contains information about the current context and is useful for helpers that want to change the current context or render internal blocks.

As all instances of dom::Function, the helper should also return a dom::Value. If the function semantics does not require a return value, the function should return a dom::Value of type dom::Kind::Undefined.

When the helper is used in an subexpression, the dom::Value return value is used as the intermediary result. When the helper is used in a block or a final expression, the dom::Value return value will be formatted to the output.

Parameters

Name Description

name

The name of the helper in the handlebars template

helper

The helper function

See Also

https://handlebarsjs.com/guide/expressions.html

https://handlebarsjs.com/guide/block‐helpers.html

https://handlebarsjs.com/guide/builtin‐helpers.html

Created with MrDocs