Exemplo n.º 1
0
 /// <summary>
 /// 从缓存中读取部分模板内容
 /// </summary>
 /// <param name="templateId"></param>
 /// <returns></returns>
 internal static string ReadPartial(string templateId)
 {
     if (TemplateCache.Exists(templateId))
     {
         return(TemplateCache.GetTemplateContent(templateId));
     }
     return(null);
 }
Exemplo n.º 2
0
        /// <summary>
        /// 从缓存中读取部分模板内容
        /// </summary>
        /// <param name="templateName"></param>
        /// <returns></returns>
        internal static string ReadPartial(string templateName)
        {
            var partName = templateName.Replace(".html", "");

            if (partName.Length > 0 && partName[0] != '/')
            {
                partName = "/" + partName;
            }
            if (TemplateCache.Exists(partName))
            {
                return(TemplateCache.GetTemplateContent(partName));
            }
            return(null);
        }
Exemplo n.º 3
0
        public string Compile()
        {
            // 从缓存中获取模板内容
            if (this._templateHtml == null && !String.IsNullOrEmpty(this._templateId))
            {
                this._templateHtml = TemplateCache.GetTemplateContent(this._templateId);
            }

            this.BeforeCompile(this._templateHtml);

            //HttpContext.Current.Response.Write("<br />1." + (DateTime.Now - dt).Milliseconds.ToString());
            //初始化之前发生
            this.PreInit(this.TemplateHandleObject, ref _templateHtml);
            //如果参数不为空,则替换标签并返回内容

            /*
             * if (this._data.Count != 0)
             * {
             *  foreach (string key in this._data.Keys)
             *  {
             *      _templateHtml = TemplateRegexUtility.ReplaceHtml(_templateHtml, key, this._data[key].ToString());
             *  }
             * }
             */

            //  HttpContext.Current.Response.Write("<br />2." + (DateTime.Now - dt).Milliseconds.ToString());
            //执行模板语法
            _templateHtml = Eval.Compile(_dc, _templateHtml, this.TemplateHandleObject);
            _templateHtml = this.ReplaceDefinedVariables(_templateHtml);


            // HttpContext.Current.Response.Write("<br />3." + (DateTime.Now - dt).Milliseconds.ToString());

            //解析实体的值
            //templateHtml = Eval.ExplanEntityProperties(dc,templateHtml);

            //呈现之前处理
            this.PreRender(this.TemplateHandleObject, ref _templateHtml);

            // HttpContext.Current.Response.Write("<br />4."+(DateTime.Now - dt).Milliseconds.ToString());

            return(_templateHtml);
        }
Exemplo n.º 4
0
 internal static string Read(string templateId)
 {
     //从缓存中获取模板内容
     return(TemplateCache.GetTemplateContent(templateId.ToLower()));
 }