protected override System.Linq.Expressions.Expression VisitDeferredSectionExpression(DeferredSectionExpression dsex) { #if netstandard var method = new Action <object, BindingContext, Action <TextWriter, object>, Action <TextWriter, object> >(RenderSection).GetMethodInfo(); #else var method = new Action <object, BindingContext, Action <TextWriter, object>, Action <TextWriter, object> >(RenderSection).Method; #endif System.Linq.Expressions.Expression path = HandlebarsExpression.PathExpression(dsex.Path.Path.Substring(1)); System.Linq.Expressions.Expression context = CompilationContext.BindingContext; System.Linq.Expressions.Expression[] templates = GetDeferredSectionTemplates(dsex); return(System.Linq.Expressions.Expression.Call(method, new[] { path, context }.Concat(templates))); }
public IEnumerable <object> ConvertTokens(IEnumerable <object> sequence) { foreach (var item in sequence) { if (item is WordExpressionToken wordExpressionToken) { yield return(HandlebarsExpression.PathExpression(wordExpressionToken.Value)); } else { yield return(item); } } }
private static object ParseValue(string value) { if (value.StartsWith("'") || value.StartsWith("\"")) { return(value.Trim('\'', '"')); } if (bool.TryParse(value, out bool boolValue)) { return(boolValue); } if (int.TryParse(value, out int intValue)) { return(intValue); } return(HandlebarsExpression.PathExpression(value)); }