예제 #1
0
        public static string Populate(cmSite site, string lang, string path, object data = null, object config = null, bool isDataJson = false)
        {
            string template          = HtmlSnippet.Get(site, lang, path, config);
            JavaScriptSerializer jss = new JavaScriptSerializer();
            string encodedData       = null;

            if (isDataJson)
            {
                if (data != null)
                {
                    encodedData = data as string;
                }
                else
                {
                    encodedData = "{}";
                }
            }
            else
            {
                encodedData = jss.Serialize(data);
            }
            try
            {
                return(Render(template, encodedData));
            }
            catch (Exception ex)
            {
                Logger.Exception(ex);
                return(ex.Message);
            }
        }
예제 #2
0
        public static string ClientTemplate(this ViewUserControlEx viewControl, string path, string id, object config = null)
        {
            string output = string.Format(CultureInfo.InvariantCulture
                                          , "<script type=\"text/html\" id=\"{0}\">\n{1}\n</script>"
                                          , id.SafeHtmlEncode()
                                          , HtmlSnippet.Get(null, null, ResolveViewControlPath(viewControl, path), config)
                                          );

            return(output);
        }
예제 #3
0
 public static string PopulateTemplateWithJson(this ViewUserControlEx viewControl, string path, string json = "null", object config = null)
 {
     path = ResolveViewControlPath(viewControl, path);
     return(HtmlSnippet.Populate(null, null, path, json, config, true));;
 }
예제 #4
0
 public static string PopulateTemplate(this ViewUserControlEx viewControl, string path, object data = null, object config = null)
 {
     path = ResolveViewControlPath(viewControl, path);
     return(HtmlSnippet.Populate(null, null, path, data, config));;
 }
예제 #5
0
 public static string PopulateTemplate(this ViewMasterPage viewMasterPage, string path, object data = null, object config = null)
 {
     path = ResolveViewMasterPagePath(viewMasterPage, path);
     return(HtmlSnippet.Populate(null, null, path, data, config));;
 }