Using master layouts in a direct usage scenario with views stored as embedded resources?

4 views
Skip to first unread message

Seth Petry-Johnson

unread,
Feb 26, 2010, 10:05:57 AM2/26/10
to Spark View Engine Dev
I am currently using Spark in a direct usage scenario to render views
stored as embedded resources in my assembly. It works fine, mostly
following the Direct Usage samples in the download package.

However, I can't seem to use master layouts in this scenario; my view
renders, but without the content from the master.

Am I doing something wrong, or can I not use "<use master ...'>" when
the templates are sourced from embedded resources?

------ myview.spark ------
<use master="master.spark" />
My view goes here

------ master.spark ------
<div>Start of Master</div>
<use content="view" />
<div>End of Master</div>

------ myRenderer.cs------
var view = (SparkView)m_engine.CreateInstance(
new SparkViewDescriptor()
.AddTemplate("master.spark")
.AddTemplate("myview.spark")
);

using (var writer = new StringWriter()) {
view.RenderView(writer);
return writer.ToString();
}

Louis DeJardin

unread,
Mar 1, 2010, 12:44:38 AM3/1/10
to Spark View Engine Dev
You shouldn't need to have both "AddTemplate" and "<use master/>" -
one or the other should be sufficient. It might actually be the
element stopping the AddTemplate from working.

Also - try changing the order of the templates. IIRC they should be
innermost-first.

Seth Petry-Johnson

unread,
Mar 3, 2010, 12:40:05 PM3/3/10
to Spark View Engine Dev
Thanks for the reply! Removing the <use.../> element and adding the
templates in reverse order (view, then master) works fine.

Allowing views to specify their own master via the <use> element is a
better fit for my requirements, but I can't get it to work that way
regardless of whether or not I programmatically add the master
template to the view descriptor. Is there any reason that <use> just
won't work in a direct-usage scenario? If not, where should I begin
troubleshooting?

Thanks!

Reply all
Reply to author
Forward
0 new messages