public static bool TryGetPage(this TemplateScopeContext scope, string virtualPath, out TemplatePage page, out TemplateCodePage codePage)
        {
            if (scope.PageResult.Partials.TryGetValue(virtualPath, out page))
            {
                codePage = null;
                return(true);
            }

            if (!scope.Context.TryGetPage(scope.PageResult.VirtualPath, virtualPath, out page, out codePage))
            {
                return(false);
            }

            codePage?.Init();

            if (codePage is IRequiresRequest requiresRequest)
            {
                if (scope.GetValue(TemplateConstants.Request) is IRequest request)
                {
                    requiresRequest.Request = request;
                }
            }

            return(true);
        }
Beispiel #2
0
        public static void TryGetPage(this TemplateScopeContext scope, string virtualPath, out TemplatePage page, out TemplateCodePage codePage)
        {
            scope.Context.TryGetPage(scope.PageResult.VirtualPath, virtualPath, out page, out codePage);
            codePage?.Init();

            if (codePage is IRequiresRequest requiresRequest)
            {
                if (scope.GetValue(TemplateConstants.Request) is IRequest request)
                {
                    requiresRequest.Request = request;
                }
            }
        }