SuperSimpleViewEngine icon indicating copy to clipboard operation
SuperSimpleViewEngine copied to clipboard

Context Conditional not working in Nancy

Open thecopy opened this issue 12 years ago • 1 comments

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);
}

thecopy avatar Jul 23 '13 13:07 thecopy

By referencing Nancy and in the test using

var context = new { ViewBag = (dynamic) new DynamicDictionary() };

Makes it behave like Nancy

thecopy avatar Jul 23 '13 13:07 thecopy