Esempio n. 1
0
        public IEncodedString RenderTemplate(String templateRelPath, NBrightRazor model)
        {
            var TemplateData = "";
            var strOut       = "";
            var templatePath = HttpContext.Current.Server.MapPath(templateRelPath);

            if (File.Exists(templatePath))
            {
                string inputLine;
                var    inputStream  = new FileStream(templatePath, FileMode.Open, FileAccess.Read);
                var    streamReader = new StreamReader(inputStream);

                while ((inputLine = streamReader.ReadLine()) != null)
                {
                    TemplateData += inputLine + Environment.NewLine;
                }
                streamReader.Close();
                inputStream.Close();

                if (TemplateData.Contains("AddPreProcessMetaData("))
                {
                    // do razor and cache preprocessmetadata
                    // Use the filename to link the preprocess data in cache, this shoud have been past as the param on the @AddPreProcessMetaData razor token in hte template.
                    var razorTempl = RazorUtils.RazorRender(model, TemplateData, "preprocessmetadata" + Path.GetFileName(templatePath), false);
                }

                strOut = RazorUtils.RazorRender(model, TemplateData, "", false);
            }

            return(new RawString(strOut));
        }
Esempio n. 2
0
        public IEncodedString RenderTemplate(String templateRelPath, NBrightRazor model)
        {
            var TemplateData = "";
            var strOut       = "";
            var templatePath = HttpContext.Current.Server.MapPath(templateRelPath);

            if (File.Exists(templatePath))
            {
                string inputLine;
                var    inputStream  = new FileStream(templatePath, FileMode.Open, FileAccess.Read);
                var    streamReader = new StreamReader(inputStream);

                while ((inputLine = streamReader.ReadLine()) != null)
                {
                    TemplateData += inputLine + Environment.NewLine;
                }
                streamReader.Close();
                inputStream.Close();

                strOut = RazorUtils.RazorRender(model, TemplateData, templatePath, false);
            }

            return(new RawString(strOut));
        }