Spark view engine - passing model to partial view
It would like to iterate through list and render partial view for each element:
<for each="Element elem in elements">
<render partial="partialViewName">
</for>
How should I pass elem to partial view? <render partial> doesn't have additional parameters. I can use html.RenderPartial, but I would like to use Spark syntax. Is it possible? It looks as if it needed to use the same ViewData and couldn't define its own model.
EDIT:
Partial view:
${elem.ID}
OK. I can use 'elem' in partial view, but partial view doesn't know what ty开发者_如何学Pythonpe 'elem' is. Of course everything will work, because generated view class compiles, but I have no Intellisense in partial view.
<viewdata paramname="paramtype"/>
Also I never used render, I use <use name="partialname" param1="value" param2="value" .../> - maybe it's the same as render, I don't know. But defining your parameters in viewdata as shown above should also work.
Also note the <default /> element, not for this exactly question, but can also be useful since sometimes you'd want some partial parameters to be optional.
Well, I don't use Spark View Engine. But it appears <render partial>
does have additional parameters. See here.
So I'm guessing you need to expose a property in your partial view and set its value via with *="" assignments.
精彩评论