spark-view-engine

Is is Possible to Use a Master Layout when using Spark in the form of the Direct Usage Example


Is is possible to use a master layout when using Spark in the form of the Direct Usage Sample? I have tried using both in my layout with my master layout in the same folder as the calling layout and I have also tried adding the master layout as a template to the SparkViewDescriptor in the code below?

    public class DefaultMessageBuilder : MessageBuilder 
    { 
        private readonly ISparkViewEngine _engine; 
        public DefaultMessageBuilder() 
        { 
            var settings = new SparkSettings() 
                .SetDebug(true) 
                .SetPageBaseType(typeof(TemplateBase)) 
                .AddNamespace("System.Collections.Generic"); 
            var templates = new VirtualPathProviderViewFolder("~/Templates"); 
            _engine = new SparkViewEngine(settings) { ViewFolder = templates }; 
        } 
        public override void Transform(string templateName, object data, TextWriter output) 
        { 
            var descriptor = new SparkViewDescriptor() 
                .AddTemplate("Master.spark") 
                .AddTemplate(templateName + ".spark"); 
            var view = (TemplateBase)_engine.CreateInstance(descriptor); 
            try 
            { 
                view.ViewData = new ViewDataDictionary(data); 
                view.RenderView(output); 
            } 
            finally 
            { 
                _engine.ReleaseInstance(view); 
            } 
        } 
    } 

Solution

  • It look like for my particular situation where I want to have standard header and footer I can use file includes like this: <use file="~/Layouts/Master" />.