sebastienros/fluid

ViewStart can't influence layout anymore

Closed this issue · 0 comments

Still updating from Fluid 2.2.0 to the newest version (turns out it's not that easy :D). I found another behaviour change. I guess it's best described by the test case I reduced it to:

[Fact]
public async Task LayoutShouldBeAbleToIncludeVarsFromViewStart()
{
    _mockFileProvider.Add("Views/Index.liquid", "{% layout '_Layout' %}[View]");
    _mockFileProvider.Add("Views/_Layout.liquid", "[Layout]{% renderbody %}{{OnlineHelpUrl}}");
    _mockFileProvider.Add("Views/_ViewStart.liquid", "[ViewStart]{%- assign OnlineHelpUrl = 'https://help.orgadata.com/en/' -%}");

    var sw = new StringWriter();
    await _renderer.RenderViewAsync(sw, "Index.liquid", new TemplateContext());
    await sw.FlushAsync();
    Assert.Equal("[Layout][ViewStart][View]https://help.orgadata.com/en/", sw.ToString());
}

This worked in 2.20 but since this PR, it does not work anymore. Turns out

// A template is evaluated in a child scope such that the provided TemplateContext is immutable
context.EnterChildScope();

also applies to the scope of _ViewStart.liquid 😄.

That is not an intended change, is it?