SuperSimpleViewEngine
SuperSimpleViewEngine copied to clipboard
Context Conditional not working in Nancy
This SSVE markup:
@Context.ViewBag.HaveMessage;<br />
@If.Context.ViewBag.HaveMessage;
Yay Message!
@EndIf;
Produces in Nancy:
True
Produces in SSVE test:
True
Yay Message!
[Fact]
public void Should_evaluate_context_conditional()
{
const string input = @"@Context.ViewBag.HaveMessage;! @If.Context.ViewBag.HaveMessage;Yay message!@EndIf;";
var context = new { ViewBag = (dynamic)new ExpandoObject() };
context.ViewBag.HaveMessage = true;
((FakeViewEngineHost)this.fakeHost).Context = context;
var output = viewEngine.Render(input, null, this.fakeHost);
Assert.Equal(@"True! Yay message!", output);
}
By referencing Nancy and in the test using
var context = new { ViewBag = (dynamic) new DynamicDictionary() };
Makes it behave like Nancy