This project is read-only.

Strong-typing RenderSection names

Sep 27, 2012 at 8:21 AM

Hi Team,

   Just discovered T4MVC this week and have been refracting a new project I have been working on. It is simply so satisfying to have the strings removed out of the templates and views and strong typing the needed logic. Thank you all for that.

I do have a request, is it possible to list the possible "section" names from the layout views so that can be strong typed in @RenderSection calls?

Thank you

Sep 27, 2012 at 1:13 PM

I think that would be possible in theory, but non-trivial to implement as it would require parsing views, which T4MVC currently never does. All it does is parse code (using the VS code model) and enumerate view files.

Doesn't mean it can't be done, but it's not a small change :)

Sep 27, 2012 at 2:30 PM

I understand, thank you for the reply.

I guess the advantage is also very minimal compared to the effort. And it is not like we are going to have a huge number of layout pages were the same sections are going to be reused. Above all else the section names in the view are already strongly typed as a non-string value so even if we are presented with a collection of section names based on the layout the view is inheriting from it will not be much helpful.

I will stick with the magic strings for the render section :)

Thank you.