| HandlebarsViewEngineRegisterHelper Method (String, HandlebarsHelper) |
Namespace: HandlebarsDotNet.Mvc
public virtual void RegisterHelper( string helperName, HandlebarsHelper helperFunction )
var hbsve = new HandlebarsViewEngine(); hbsve.RegisterHelper("link_to", (writer, context, parameters) => { writer.WriteSafeString("<a href='" + context.url + "'>" + context.text + "</a>"); });
public ActionResult Index() { var data = new { url = "https://github.com/rexm/handlebars.net", text = "Handlebars.Net" }; return View(data); }
Click here: {{link_to}}Click here: <a href='https://github.com/rexm/handlebars.net'>Handlebars.Net</a>