예제 #1
0
        public IfCond()
        {
            HandlebarsDotNet.Handlebars.RegisterHelper("ifCond", (writer, options, context, parameters) =>
            {
                if (parameters.Length != 3)
                {
                    options.Inverse(writer, context);
                }
                else
                {
                    var param0 = string.Empty;
                    var param1 = string.Empty;
                    var param2 = string.Empty;

                    try { param0 = EnumResolver.Convert(parameters[0]).ToString(); } catch { }
                    try { param1 = parameters[1].ToString(); } catch { }
                    try { param2 = EnumResolver.Convert(parameters[2])?.ToString(); } catch { }

                    if (checkCondition(param0, param1, param2))
                    {
                        options.Template(writer, context);
                    }
                    else
                    {
                        options.Inverse(writer, context);
                    }
                }
            });
        }
예제 #2
0
 public Enum()
 {
     HandlebarsDotNet.Handlebars.RegisterHelper("enum", (writer, context, parameters) =>
     {
         writer.WriteSafeString(EnumResolver.Convert(parameters[0]));
     });
 }