partial layouts (layouts for partials)

9 views
Skip to first unread message

Craig Quillen

unread,
Oct 14, 2009, 2:16:37 AM10/14/09
to Spark View Engine Dev
I am trying to use the MvcContrib InputBuilders with spark and I'm
getting some strange results. Subsequent calls to Html.Input(...)
output the fields from the previous calls.

1st Html.Input() call outputs one field.
2nd call outputs 2 fields
3rd call outputs 3 fields, etc.

I have traced this down to how the input builder views use a partials
and layouts. There is a seperate partial for each field type (string,
bool, password, etc.). Each of these partials references a "field"
layout that outputs the label, validation message, etc.

The layout seems to be cacheing and re-rendering the content.

Here is an example:


test.spark file:

<html>
<body>

#Html.RenderPartial("foo", null, "fooLayout");
#Html.RenderPartial("foo", null, "fooLayout");
#Html.RenderPartial("foo", null, "fooLayout");

</body>
</html>


fooLayout.spark file:

<p>before content</p>
<use content="fooContent"/>
<p>after content</p>


foo.spark file:

<content name="fooContent">
<p>hello world</p>
</content>


output of test.spark (hello world stack up with each call to foo):

<html>
<body>
<p>before content</p>
<p>hello world</p>
<p>after content</p>
<p>before content</p>
<p>hello world</p>
<p>hello world</p>
<p>after content</p>
<p>before content</p>
<p>hello world</p>
<p>hello world</p>
<p>hello world</p>
<p>after content</p>

</body>
</html>



expected output (one hello world per call to foo.spark):

<html>
<body>
<p>before content</p>
<p>hello world</p>
<p>after content</p>
<p>before content</p>
<p>hello world</p>
<p>after content</p>
<p>before content</p>
<p>hello world</p>
<p>after content</p>

</body>
</html>
























Eric Hexter

unread,
Oct 14, 2009, 9:25:01 AM10/14/09
to spar...@googlegroups.com
I cannot offer anything about the spark portion but I will monitor this thread if there are any changed needed to mvccontrib to better support the builders for this viewengine.
 
Eric

Craig Quillen

unread,
Oct 14, 2009, 10:01:54 AM10/14/09
to Spark View Engine Dev
Thx Eric,

This is when using spark for the input builder templates BTW.

When using the webforms input templates that come out of the box
within a spark view, the inputs are rendered at the start of the
output instead of at the location of the Html.Input() call.

I figured this was due to the webforms engine writing directly to the
response before spark does it thing, so I rewrote a handful of the
input templates in spark. This fixed the output location issue, but
then I ran into the content duplication issue with the spark layouts
previously discussed.

It seems like spark layouts are not expecting to be called multiple
times within a single request and are not cleaning up their internal
state.

-Craig
> > </html>- Hide quoted text -
>
> - Show quoted text -

Louis DeJardin

unread,
Oct 14, 2009, 11:12:18 PM10/14/09
to spar...@googlegroups.com
Pretty sure what you're seeing is a feature - named content is meant to be cumulative, and if you capture something even in in an call to mvc's Html.RenderPartial it can be used from the views and layouts once it's returned.

A practical example of that would be a partial that adds js or css to a <content name="head"> capture.

To prevent that I believe you should be able to destroy the content once it's been used with something like

<use content="fooContent/>
#Content.Remove("fooContent");

Craig Quillen

unread,
Oct 16, 2009, 9:28:24 AM10/16/09
to Spark View Engine Dev
I'll give that a try and post the results here.

Is there any documentation on how layouts work? Well... I guess what
I'm really looking for is a description of the whole rendering
process. I was expecting it to work more or less the same way as
webforms, which obviously isn't the case.
> > > - Show quoted text -- Hide quoted text -

Louis DeJardin

unread,
Oct 17, 2009, 5:11:53 PM10/17/09
to Spark View Engine Dev
Documentation's pretty thin in parts, but might be some stuff in
http://sparkviewengine.com/documentation/master-layouts that relates.

SteveMason

unread,
Nov 9, 2009, 7:27:28 PM11/9/09
to Spark View Engine Dev
Hi all,

For what it's worth I just ran into this problem myself and Louis' fix
worked great.

Thanks a lot,
Steve

On Oct 17, 9:11 pm, Louis DeJardin <louis.dejar...@gmail.com> wrote:
> Documentation's pretty thin in parts, but might be some stuff inhttp://sparkviewengine.com/documentation/master-layoutsthat relates.

Dani

unread,
Nov 17, 2009, 12:11:28 PM11/17/09
to Spark View Engine Dev
For those of you lucky enough to have made the Input Builders work in
Spark, I will REALLY appreciate if you could share how you make this
work? I have been banging my head with this three hours today, but I
don't seem to find the right configuration. What code do you place on
your Application_Start()? Thank you very much.

Dani

unread,
Nov 19, 2009, 3:40:01 PM11/19/09
to Spark View Engine Dev
Craig,

How did you deal with the limitation Spark has of only one viewdata
model? I tried to convert the templates to Spark, and ran into the
issue of different templates using different strongly-typed models,
and Spark not allowing this.

Dani

queen3

unread,
Nov 19, 2009, 4:03:22 PM11/19/09
to Spark View Engine Dev
I'm also interested, so if anyone can provide a solution, that would
be great. Except that for me InputBuilders didn't work at all, I don't
remember why, but it's highly possible that's because I use Spark.

Daniel Liuzzi

unread,
Nov 19, 2009, 4:11:25 PM11/19/09
to spar...@googlegroups.com
queen3,

You must use the latest dev build of Spark. For more information refer to this answer in SO http://stackoverflow.com/questions/1750242/how-can-i-make-input-builders-mvc-contrib-work-with-spark-view-engine/1758049#1758049

Dani

--

You received this message because you are subscribed to the Google Groups "Spark View Engine Dev" group.
To post to this group, send email to spar...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spark-dev?hl=.





--

Stephen Leacock  - "I detest life-insurance agents: they always argue that I shall some day die, which is not so."
Reply all
Reply to author
Forward
0 new messages