Re: Direct Usage of Spark Engine

49 views
Skip to first unread message

RobertTheGrey

unread,
Jan 29, 2013, 5:36:58 AM1/29/13
to spar...@googlegroups.com
I'm guessing a bit here because I can't see your folder structure. If you create a folder called "Shared" in the same folder as the view you're trying to render and put your master (Application.spark) in that folder, then it *should* pick it up.

To determine any more will probably require more code (gist?) or a zip file with a small repro in it to debug.

Cheers,
Rob

On Tuesday, January 29, 2013 12:08:02 AM UTC, Jesse Williamson wrote:
I've got some code where I'm trying to use the SparkViewEngine directly, like in some of the Samples on GitHub (https://github.com/SparkViewEngine/spark/blob/master/src/Samples/DirectUsage/ConsoleTemplating/Services/DefaultMessageBuilder.cs)

I'm able to get templates to render fine, until I try to include master pages. I get the content rendered, but without the master. The code looks like this:
var settings = new SparkSettings();
            settings.SetPageBaseType(typeof (WebApiSparkView));
            var engine = new SparkViewEngine(settings);
            var descriptor = new SparkViewDescriptor().AddTemplate(view.ViewName + ".spark");
            var entry = engine.CreateInstance(descriptor);
            var writer = new StringWriter();
            entry.RenderView(writer);
            return writer.ToString();

Do I need to add anything else to get the default layout conventions (/Views/Shared/Application.spark, etc)?

Also, I would like to add .shade support, but I've found that adding another Template to the descriptor is fail.

Thanks for the help.

Jesse Williamson

unread,
Jan 29, 2013, 9:05:33 PM1/29/13
to spar...@googlegroups.com
Thanks Rob, I realize I left some stuff out, but you guessed correctly on my folder structure. I've got a Views folder at the root of my project, and a Shared folder within that with an Application.spark. I worked around it by checking for the existence of a Application view in ~/Views/Shared and ~/Views/Layouts (added .shade in for fun too). It's a bit manual, but it works. I'll see if I can get some time to push a repo up to GitHub; pretty sure I've missed something.

Thanks for the help.
Reply all
Reply to author
Forward
0 new messages