예제 #1
0
파일: View.cs 프로젝트: nchapman/monarch
        public string Run(ViewDictionary data)
        {
            var cacheKey = controller + view + layout;

            var template = HttpContext.Current.Cache[cacheKey] as BoostTemplate;

            if (null == template)
            {
                var s = Path.DirectorySeparatorChar;

                var viewPath = Path.Combine(applicationPath, string.Format("Views{0}{1}{0}{2}.rhtml", s, controller, view));
                var layoutPath = Path.Combine(applicationPath, string.Format("Views{0}Layouts{0}{1}.rhtml", s, layout));

                var viewText = File.ReadAllText(viewPath);
                var layoutText = File.ReadAllText(layoutPath);

                template = new BoostTemplate(viewText, layoutText);

                HttpContext.Current.Cache.Insert(cacheKey, template, new CacheDependency(new[] { viewPath, layoutPath }));
            }

            return template.Run(data);
        }
예제 #2
0
        public void TestBrailCodeWrite()
        {
            var template = new BoostTemplate("<%= \"Hello\" %>");

            Assert.AreEqual(template.Run(), "Hello");
        }
예제 #3
0
        public void TestBrailCode()
        {
            var template = new BoostTemplate("<% output.Append(1+2) %>");

            Assert.AreEqual(template.Run(), "3");
        }