Esempio n. 1
0
        private static bool CreateIncludeFile(IncludeFileInfo includeFileInfo)
        {
            if (includeFileInfo.IsNull)
            {
                return(false);
            }
            string includeFilePath = SiteConfig.SiteOption.IncludeFilePath;

            includeFilePath = "~/" + includeFilePath + "/" + includeFileInfo.FileName;
            includeFilePath = HttpContext.Current.Request.MapPath(includeFilePath);
            TemplateInfo templateInfo = new TemplateInfo();

            templateInfo.QueryList       = new NameValueCollection();
            templateInfo.PageName        = "";
            templateInfo.TemplateContent = includeFileInfo.Template;
            templateInfo.RootPath        = HttpContext.Current.Request.PhysicalApplicationPath;
            templateInfo.CurrentPage     = 1;
            string templateContent = TemplateTransform.GetHtml(templateInfo).TemplateContent;

            if (includeFileInfo.IncludeType == IncludeType.JSWriteHtml)
            {
                templateContent = "document.write(\"" + DataSecurity.ConvertToJavaScript(templateContent) + "\")";
            }
            FileSystemObject.WriteFile(includeFilePath, templateContent);
            return(true);
        }
        /// <summary>
        /// 获取html代码,页面调用此方法解析
        /// </summary>
        /// <param name="templateInfo"></param>
        /// <returns></returns>
        public static TemplateInfo GetHtml(TemplateInfo templateInfo)
        {
            TemplateTransform transform = new TemplateTransform();

            return(transform.ParseHtml(templateInfo));
        }