public string RenderTemplate(string templateSource, object data) { var settings = new SparkSettings { PageBaseType = typeof(TestSparkView).Name }; settings.AddViewFolder(typeof (TestingViewFolder), new Dictionary<string, string> { {"templateSource", templateSource} }); settings.AddNamespace("OpenRasta.Codecs.Spark.Tests.TestObjects"); settings.AddNamespace("OpenRasta.Codecs.Spark.IntegrationTests"); settings.AddNamespace("OpenRasta.Codecs.Spark2.ViewHelpers"); settings.AddNamespace("System.Collections.Generic"); IWindsorContainer dependencies = CreateTestDependencies(); ISparkViewEngine sparkViewEngine = new SparkViewEngine(settings) { ExtensionFactory =dependencies.Resolve<ISparkExtensionFactory>() }; var descriptor = new SparkViewDescriptor(); descriptor.AddTemplate(TestingViewFolder.SingleTemplateName); var view = (TestSparkView)sparkViewEngine.CreateInstance(descriptor); view.Uris = new UriGenerator(DependencyManager.GetService<IUriResolver>()); view.ViewData = new TestViewData(data); return Render(view); }
public ISparkSettings CreateSettings() { var settings = new SparkSettings { PageBaseType = typeof (SparkResourceView).Name }; settings.AddViewFolder(typeof (TestingViewFolder), new Dictionary<string, string> { {"templateSource", _templateSource} }); new SparkCodecNamespacesConfiguration().AddNamespaces(settings); settings.AddNamespace("OpenRasta.Codecs.Spark.Tests.TestObjects"); return settings; }
private SparkSettings CreateSparkSettings() { var result = new SparkSettings { PageBaseType = typeof (SparkResourceView).Name }; result.AddViewFolder(ViewFolderType.VirtualPathProvider, new Dictionary<string, string> {{"virtualBaseDir", "~/views/"}}); result.AddNamespace("OpenRasta.Web.Markup"); result.AddNamespace("OpenRasta.Web"); result.AddNamespace("OpenRasta.Codecs.Spark"); result.AddNamespace("System.Linq"); result.AddNamespace("OpenRasta.Codecs.Spark.Extensions"); return result; }
private static void AddViewFolder(SparkSettings result) { result.AddViewFolder(ViewFolderType.VirtualPathProvider, new Dictionary<string, string> {{"virtualBaseDir", "~/views/"}}); }