Exemplo n.º 1
0
 public static void Unless(TextWriter output, HelperOptions options, dynamic context, params object[] arguments)
 {
     if (arguments.Length != 1)
     {
         throw new HandlebarsException("{{unless}} helper must have exactly one argument");
     }
     if (HandlebarsUtils.IsFalsy(arguments[0]))
     {
         options.Template(output, context);
     }
     else
     {
         options.Inverse(output, context);
     }
 }
Exemplo n.º 2
0
        public static void With(TextWriter output, object root, HelperOptions options, dynamic context, params object[] arguments)
        {
            if (arguments.Length != 1)
            {
                throw new HandlebarsException("{{with}} helper must have exactly one argument");
            }

            if (HandlebarsUtils.IsTruthyOrNonEmpty(arguments[0]))
            {
                options.Template(output, arguments[0]);
            }
            else
            {
                options.Inverse(output, context);
            }
        }