Antaris/RazorEngine — Issue #16: Null string throws Object reference not set to an instance of an object
Author: jmojiwat
Created: 2012-01-25 17:17:19+00:00
State: open

hi,

in previous version, when i pass a null string to the parser, it will render and output as if it were an empty string. but in version 3 of razorengine, it throws an object reference not set to an instance of an object.

here's the sample code:

using (var service = new TemplateService())
{
const string template = "

Hello @Model.Person.Forename

";
const string expected = "

Hello

";

var model = new {Person = new Person {Forename = null}};
string result = service.Parse(template, model);

Assert.That(result == expected, "Result does not match expected: " + result);
}

currently, my workaround is to not use anonymous objects and just define a class as a container for the objects i want to pass along to the parser. is there a better workaround?

thanks for the really neat engine.

jake