Wyamio / Wyam

A modular static content and static site generator.
MIT License
141 stars 29 forks source link

Razor custom view model breaks with Layout #12

Open alanta opened 4 years ago

alanta commented 4 years ago

Setting a custom model for a Razor view while also using a layout and viewstart file causes an error similar to this:

Exception while processing document /ViewStartAndLayout/Test.cshtml in module unknown: The model item passed into the ViewDataDictionary is of type 'System.Int32[]', but this ViewDataDictionary instance requires a model item of type 'Wyam.Common.Documents.IDocument'.

There are two new tests in this PR. There was no test yet for setting the view model from a delegate and the second test covers the error.

The fix I did doesn't seem to break any tests which seems, which makes me wonder why that line was there in the first place.

A bit of background: I'm working on a Wyam module that pulls in content from Kontent headless CMS. The client for that CMS supports strong typed content models which is something I'm also hoping to support with this module for Wyam.