private static void RenderSection(object value, BindingContext context, Action <TextWriter, object> body, Action <TextWriter, object> inversion) { var boolValue = value as bool?; var enumerable = value as IEnumerable; if (boolValue == true) { body(context.TextWriter, context); } else if (boolValue == false) { inversion(context.TextWriter, context); } else if (HandlebarsUtils.IsFalsyOrEmpty(value)) { inversion(context.TextWriter, context); } else if (value is string) { body(context.TextWriter, value); } else if (enumerable != null) { foreach (var item in enumerable) { body(context.TextWriter, item); } } else { body(context.TextWriter, value); } }
private static void RenderSection( object value, BindingContext context, Action <BindingContext, TextWriter, object> body, Action <BindingContext, TextWriter, object> inversion ) { switch (value) { case bool boolValue when boolValue: body(context, context.TextWriter, context); return; case null: case object _ when HandlebarsUtils.IsFalsyOrEmpty(value): inversion(context, context.TextWriter, context); return; case string _: body(context, context.TextWriter, value); return; case IEnumerable enumerable: Iterator.Iterate(context, BlockParamsVariables, enumerable, body, inversion); break; default: body(context, context.TextWriter, value); break; } }
private static void RenderEmptySection(object value, BindingContext context, Action <TextWriter, object> template) { if (HandlebarsUtils.IsFalsyOrEmpty(value) == true) { template(context.TextWriter, value); } }
private static void RenderSection(object value, BindingContext context, Action <TextWriter, object> template) { if (value is bool && (bool)value == true) { template(context.TextWriter, context); } else if (HandlebarsUtils.IsFalsyOrEmpty(value)) { return; } else if (value is IEnumerable) { foreach (var item in ((IEnumerable)value)) { template(context.TextWriter, item); } } else if (value != null) { template(context.TextWriter, value); } else { throw new HandlebarsRuntimeException("Could not render value for the section"); } }
private static void RenderSection(object value, BindingContext context, EncodedTextWriter writer, TemplateDelegate body, TemplateDelegate inversion) { switch (value) { case bool boolValue when boolValue: body(writer, context); return; case null: case object _ when HandlebarsUtils.IsFalsyOrEmpty(value): inversion(writer, context); return; case string _: { using var frame = context.CreateFrame(value); body(writer, frame); return; } case IEnumerable enumerable: Iterator.Iterate(context, writer, BlockParamsVariables, enumerable, body, inversion); break; default: { using var frame = context.CreateFrame(value); body(writer, frame); break; } } }