public void RegisterHelper(string helperName, HandlebarsHelperV2 helperFunction) { if (string.IsNullOrEmpty(helperName)) { throw new ArgumentNullException(nameof(helperName)); } if (helperFunction == null) { throw new ArgumentNullException(nameof(helperFunction)); } Configuration.Helpers.AddOrUpdate(helperName, n => helperFunction, (n, h) => helperFunction); }
private static string CaptureTextWriterOutputFromHelper( HandlebarsHelperV2 helper, IHandlebarsEngine engine, object context, object[] arguments) { var builder = new StringBuilder(); using (var writer = new StringWriter(builder)) { helper(engine, writer, context, arguments); } return(builder.ToString()); }