StubbleOrg / Stubble

Trimmed down {{mustache}} templates in .NET
Other
401 stars 58 forks source link

Compiled renderer does not throw on ambiguous views #81

Closed janhohenheim closed 4 years ago

janhohenheim commented 4 years ago

When using the setting SetIgnoreCaseOnKeyLookup(true), the behavior when passing an ambiguous view is inconsistent. On the template "{{name}}" with the view

new { Name = "foo", name = "bar" }

the regular renderer throws an StubbleException, while the compiled one simply uses the first property, resulting in "foo"

Romanx commented 4 years ago

Hey there,

Thanks for opening this issue. You're right this is definately an oversight and I get an argument exception on the default renderer since we're not handling this case gracefully.

I've added a new exception type StubbleAmbigousMatchException which will be thrown when this happens, on Compile for the compilation renderer and on Render for the standard renderer.

I'll get this merged shortly into master and after i've looked at your other issue i'll get a release out. Thanks for your clear reproduction cases

Romanx commented 4 years ago

@jnferner Thanks very much for reporting this. It has been fixed in release 1.6.3 and has now been released on nuget.

Please let us know if you have any other issues.