Issue with Two Distinct TextWriters Causing Improper Form Rendering

14 views
Skip to first unread message

Miles Lyon

unread,
Feb 14, 2012, 5:20:47 PM2/14/12
to spar...@googlegroups.com, ml...@gavant.com, kc...@gavant.com
Hi all,

I sent Louis Dejardin a message through the Spark site this morning to
explain an issue. Per his suggestion I have set up a gist repository
of a sample project demonstrating my issue here:

https://gist.github.com/1830082

What we are trying to do is use spark in a standalone application
(possibly a build task soon) to render out fixtures for our javascript
unit tests directly from the existing spark files. I pointed this
console application at a number of partials and full pages with master
layouts and didn't have any issues. However, when I started working
with a sample form from our application I encountered an issue I can't
seem to resolve.

In order to Render the View I need to set up a ViewContext and
HtmlHelper. In the process of doing that I use some mocked objects,
but most importantly I pass a TextWriter into the constructor of the
ViewContext. I then call RenderView and I'm also passing in the
TextWriter there. What seems to be occurring is that these are
writing to the file distinctly. What ends up happening is my
BeginForm extension writes the opening and close tags for the Form to
the file before any of the other content is written in. The view
renders fine when using the spark view engine through our site and
looking at it in the debugger I don't see the same issue with the
TextWriters.

Clearly I'm doing something wrong with how I'm setting up my engine or
more likely my view. The key files to see what I'm doing in my code
are FixtureProvider.cs and ViewProvider.cs.

We are, of course, happy to entertain any suggestions for best
practices although please understand that this is a bit of work in
progress for us. Obviously our primary concern is figuring out what
we aren't doing correctly in setting this up as a standalone to render
our fixtures.

thanks!

Miles

Rob G

unread,
Jul 7, 2012, 4:08:51 AM7/7/12
to spar...@googlegroups.com, ml...@gavant.com, kc...@gavant.com
Hi Miles,

Apologies for the delay in replying - I wonder if you've found a solution for this yet?

If not, then I would take a look at controlling the order in which the TextWriters are output in. Each web framework that uses Spark implements its own rendering strategy to control output ordering, and if you take a look at MVC, the Render method on the SparkView object makes use of a ViewContextWrapper object and checks for things like nested views etc. as it goes through the rendering process.

Perhaps this is something that your Fixture Render method can look at employing since you say your views render just fine when going via MVC.

Hope that helps,
Rob


Miles

--
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.
To unsubscribe from this group, send email to spark-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spark-dev?hl=en.


Reply all
Reply to author
Forward
0 new messages