예제 #1
0
 public static TemplatePage RegistEventHandlers(TemplatePage page)
 {
 	using (CmsTemplates tpl = new CmsTemplates()){
 	 	page.TemplateHandleObject = tpl;
         page.OnPreInit += PreHandler;
         page.OnPreRender += CompliedTemplate;
         return page;
 	}
 }
예제 #2
0
        /// <summary>
        /// 返回模板内容
        /// </summary>
        /// <param name="templateId"></param>
        /// <param name="pageFunc">对模板处理前操作,可以添加数据对象</param>
        public static string Require(string templateId,TemplatePageHandler pageFunc)
        {
            using (CmsTemplates tpl = new CmsTemplates())
            {
                TemplatePage page = new TemplatePage(templateId);
                //if (data != null)
                //{
                //   page.AddDataObject(data);
                //}
                page.TemplateHandleObject = tpl;
                page.OnPreInit += PreHandler;
                page.OnPreRender += CompliedTemplate;

                //注册扩展的模板解析事件
                if (OnPreRender != null) page.OnPreRender += OnPreRender;

                if (pageFunc != null) pageFunc(page);

                return page.ToString();
            }
        }