public static Path ( string path ) : HandlebarsDotNet.Compiler.PathExpression | ||
path | string | |
return | HandlebarsDotNet.Compiler.PathExpression |
protected override Expression VisitDeferredSectionExpression(DeferredSectionExpression dsex) { var method = new Action <object, BindingContext, Action <TextWriter, object>, Action <TextWriter, object> >(RenderSection).Method; Expression path = HandlebarsExpression.Path(dsex.Path.Path.Substring(1)); Expression context = CompilationContext.BindingContext; Expression[] templates = GetDeferredSectionTemplates(dsex); return(Expression.Call(method, new[] { path, context }.Concat(templates))); }
public override IEnumerable <object> ConvertTokens(IEnumerable <object> sequence) { foreach (var item in sequence) { if (item is WordExpressionToken wordExpressionToken) { yield return(HandlebarsExpression.Path(wordExpressionToken.Value)); } else { yield return(item); } } }
protected override Expression VisitDeferredSectionExpression(DeferredSectionExpression dsex) { Action <object, BindingContext, Action <TextWriter, object> > method; if (dsex.Path.Path.StartsWith("#")) { method = RenderSection; } else if (dsex.Path.Path.StartsWith("^")) { method = RenderEmptySection; } else { throw new HandlebarsCompilerException("Tried to compile a section expression that did not begin with # or ^"); } return(Expression.Call( method.Method, HandlebarsExpression.Path(dsex.Path.Path.Substring(1)), CompilationContext.BindingContext, new FunctionBuilder(CompilationContext.Configuration).Compile(dsex.Body, CompilationContext.BindingContext))); }
private static object ParseValue(string value) { if (value.StartsWith("'") || value.StartsWith("\"")) { return(value.Trim('\'', '"')); } bool boolValue; if (bool.TryParse(value, out boolValue)) { return(boolValue); } int intValue; if (int.TryParse(value, out intValue)) { return(intValue); } return(HandlebarsExpression.Path(value)); }