Click or drag to resize
HandlebarsViewEngineRegisterHelper Method (String, HandlebarsHelper)
Registers a helper in this view engine's global configuration.

Namespace: HandlebarsDotNet.Mvc
Assembly: HandlebarsDotNet.Mvc (in HandlebarsDotNet.Mvc.dll) Version: 1.0.0-beta
Syntax
public virtual void RegisterHelper(
	string helperName,
	HandlebarsHelper helperFunction
)

Parameters

helperName
Type: SystemString
The name of the helper.
helperFunction
Type: HandlebarsHelper
The function body for this helper.
Remarks
If you call this after the view engine has been registered, you need to call the ClearCache(ControllerContext) method.
Examples
C#
var hbsve = new HandlebarsViewEngine();
hbsve.RegisterHelper("link_to", (writer, context, parameters) => {
  writer.WriteSafeString("<a href='" + context.url + "'>" + context.text + "</a>");
});
controller
public ActionResult Index()
{
    var data = new {
        url = "https://github.com/rexm/handlebars.net",
        text = "Handlebars.Net"
    };
    return View(data);
}
view.hbs
Click here: {{link_to}}
Renders
Click here: <a href='https://github.com/rexm/handlebars.net'>Handlebars.Net</a>
See Also