public static DeferredSectionExpression DeferredSection( PathExpression path, IEnumerable<Expression> body, SectionEvaluationMode evalMode) { return new DeferredSectionExpression(path, body, evalMode); }
public static DeferredSectionExpression DeferredSection( PathExpression path, BlockExpression body, BlockExpression inversion) { return new DeferredSectionExpression(path, body, inversion); }
protected override Expression VisitPathExpression(PathExpression pex) { var context = ExpressionShortcuts.Arg <BindingContext>(CompilationContext.BindingContext); var pathInfo = pex.PathInfo; return(ExpressionShortcuts.Call(() => PathResolver.ResolvePath(context, ref pathInfo))); }
public static DeferredSectionExpression DeferredSection( PathExpression path, IEnumerable <Expression> body, SectionEvaluationMode evalMode) { return(new DeferredSectionExpression(path, body, evalMode)); }
public static DeferredSectionExpression DeferredSection( PathExpression path, BlockExpression body, BlockExpression inversion) { return(new DeferredSectionExpression(path, body, inversion)); }
protected override Expression VisitPathExpression(PathExpression pex) { return(Expression.Call( Expression.Constant(this), new Func <BindingContext, string, object>(ResolvePath).Method, CompilationContext.BindingContext, Expression.Constant(pex.Path))); }
protected override Expression VisitPathExpression(PathExpression pex) { return Expression.Call( Expression.Constant(this), new Func<BindingContext, string, object>(ResolvePath).Method, CompilationContext.BindingContext, Expression.Constant(pex.Path)); }
public DeferredSectionExpression( PathExpression path, IEnumerable <Expression> body, SectionEvaluationMode evalMode) { _path = path; _body = body; _evalMode = evalMode; }
public DeferredSectionExpression( PathExpression path, BlockExpression body, BlockExpression inversion) { Path = path; Body = body; Inversion = inversion; }
private static bool IsPartialBlock(Expression item) { item = UnwrapStatement(item); return(item switch { PathExpression expression => expression.Path.StartsWith("#>"), HelperExpression helperExpression => helperExpression.HelperName.StartsWith("#>"), _ => false, });
public DeferredSectionExpression( PathExpression path, IEnumerable<Expression> body, SectionEvaluationMode evalMode) { _path = path; _body = body; _evalMode = evalMode; }
protected override Expression VisitPathExpression(PathExpression pex) { return Expression.Call( Expression.Constant(this), #if netstandard new Func<BindingContext, string, object>(ResolvePath).GetMethodInfo(), #else new Func<BindingContext, string, object>(ResolvePath).Method, #endif CompilationContext.BindingContext, Expression.Constant(pex.Path)); }
protected override Expression VisitPathExpression(PathExpression pex) { return(Expression.Call( Expression.Constant(this), #if netstandard new Func <BindingContext, string, object>(ResolvePath).GetMethodInfo(), #else new Func <BindingContext, string, object>(ResolvePath).Method, #endif CompilationContext.BindingContext, Expression.Constant(pex.Path))); }
protected virtual Expression VisitDeferredSectionExpression(DeferredSectionExpression dsex) { PathExpression path = (PathExpression)Visit(dsex.Path); // Don't visit Body/Inversion - they will be compiled separately if (path != dsex.Path) { return(HandlebarsExpression.DeferredSection(path, dsex.Body, dsex.Inversion)); } return(dsex); }
protected override Expression VisitPathExpression(PathExpression pex) { var bindingContext = CompilationContext.Args.BindingContext; var configuration = CompilationContext.Configuration; var pathInfo = PathInfoStore.Current.GetOrAdd(pex.Path); var resolvePath = Call(() => PathResolver.ResolvePath(bindingContext, pathInfo)); if (pex.Context == PathExpression.ResolutionContext.Parameter) { return(resolvePath); } if (pathInfo.IsVariable || pathInfo.IsThis) { return(resolvePath); } if (!pathInfo.IsValidHelperLiteral && !configuration.Compatibility.RelaxedHelperNaming) { return(resolvePath); } var pathInfoLight = new PathInfoLight(pathInfo); if (!configuration.Helpers.TryGetValue(pathInfoLight, out var helper)) { // TODO: use IHelperResolver here as well var lateBindHelperDescriptor = new LateBindHelperDescriptor(pathInfo); helper = new Ref <IHelperDescriptor <HelperOptions> >(lateBindHelperDescriptor); configuration.Helpers.AddOrReplace(pathInfoLight, helper); } else if (configuration.Compatibility.RelaxedHelperNaming) { pathInfoLight = pathInfoLight.TagComparer(); if (!configuration.Helpers.ContainsKey(pathInfoLight)) { var lateBindHelperDescriptor = new LateBindHelperDescriptor(pathInfo); helper = new Ref <IHelperDescriptor <HelperOptions> >(lateBindHelperDescriptor); configuration.Helpers.AddOrReplace(pathInfoLight, helper); } } var options = New(() => new HelperOptions(pathInfo, bindingContext)); var context = New(() => new Context(bindingContext)); var argumentsArg = New(() => new Arguments(0)); return(Call(() => helper.Value.Invoke(options, context, argumentsArg))); }
protected override Expression VisitPathExpression(PathExpression pex) { var context = CompilationContext.Args.BindingContext; var configuration = CompilationContext.Configuration; var pathInfo = configuration.PathInfoStore.GetOrAdd(pex.Path); var resolvePath = Call(() => PathResolver.ResolvePath(context, pathInfo)); if (pex.Context == PathExpression.ResolutionContext.Parameter) { return(resolvePath); } if (pathInfo.IsVariable || pathInfo.IsThis) { return(resolvePath); } if (!pathInfo.IsValidHelperLiteral && !configuration.Compatibility.RelaxedHelperNaming) { return(resolvePath); } var pathInfoLight = new PathInfoLight(pathInfo); if (!configuration.Helpers.TryGetValue(pathInfoLight, out var helper)) { helper = new StrongBox <HelperDescriptorBase>(new LateBindHelperDescriptor(pathInfo, configuration)); configuration.Helpers.Add(pathInfoLight, helper); } else if (configuration.Compatibility.RelaxedHelperNaming) { pathInfoLight = pathInfoLight.TagComparer(); if (!configuration.Helpers.ContainsKey(pathInfoLight)) { helper = new StrongBox <HelperDescriptorBase>(new LateBindHelperDescriptor(pathInfo, configuration)); configuration.Helpers.Add(pathInfoLight, helper); } } var argumentsArg = New(() => new Arguments(0)); return(context.Call(o => helper.Value.ReturnInvoke(o, o.Value, argumentsArg))); }
protected virtual Expression VisitPathExpression(PathExpression pex) { return pex; }
protected virtual Expression VisitPathExpression(PathExpression pex) { return(pex); }
public DeferredBlockAccumulatorContext(Expression startingNode) : base(startingNode) { startingNode = UnwrapStatement(startingNode); _startingNode = (PathExpression)startingNode; }
private static bool IsSectionOrClosingNode(PathExpression pathExpression) { return (pathExpression != null) && pathExpression.Path.IndexOfAny(new[] {'#', '/', '^'}) == 0; }
private static void VerifyBlockParamsSyntax(BlockParameterToken blockParameterToken, PathExpression pathExpression) { if (pathExpression == null) { throw new HandlebarsCompilerException("blockParams definition has incorrect syntax", blockParameterToken.Context); } if (!string.Equals("as", pathExpression.Path, StringComparison.OrdinalIgnoreCase)) { throw new HandlebarsCompilerException("blockParams definition has incorrect syntax", blockParameterToken.Context); } }
private static bool IsSectionOrClosingNode(PathExpression pathExpression) { return((pathExpression != null) && pathExpression.Path.IndexOfAny(new[] { '#', '/', '^' }) == 0); }