Nancy - Super Simple View Engine: Nested @Each

Does SSVE support nested iterators?

I look to go down the object graph in my SSVE view (see below), but I suspect nested iterators cannot go here. Is there any other approach?

I know that SSVE was intended for internal use and is not intended for full use in production, so there are no problems, but I do not want to add a link to Razor and ruin my web.config file, unless I need it.

Nested iterator view (my best guess)

@Master['_Master'] @Section['Content'] <h1>Assessment - @Model.survey.title</h1> @Each.survey.pages <div> <h2>@Current.title</h2> @Each.questions <div>@Current.title</div> @EndEach </div> @EndEach @EndSection 
+8
nancy
source share
2 answers

This question is now quite old, but still appears as the top Google search result for nesting each using the Super Simple View Engine. In case anyone else encounters this, be aware that support for partial views within each has been added to SSVE. (I used it to do this kind of nesting View — iterating over collections within collections.)

So, you can achieve the effect that you want to use with two views, where the external looks like this:

 @Master['_Master'] @Section['Content'] <h1>Assessment - @Model.survey.title</h1> @Each.survey.pages <div> <h2>@Current.title</h2> @Partial['QuestionList', Current.questions] </div> @EndEach @EndSection 

And then another view (which SSVE finds with the name QuestionList) looks like this:

 @Each <div>@Current.title</div> @EndEach 

Although this leads to a fairly large number of files, you should be able to get arbitrary depth by repeating this pattern.

+18
source share

No, this will not work - SSVE is essentially just a regular expression. It should maintain a partial inside of each, but currently it does not.

+2
source share

All Articles