Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Fix for supporting nested sections in layouts #2226

Merged
merged 1 commit into from
Mar 22, 2015
Merged

Conversation

ajaybhargavb
Copy link
Contributor

@ghost ghost added the cla-not-required label Mar 20, 2015
// Verify that RenderBody is called
layoutPage.EnsureBodyWasRendered();

unRenderedSections.ExceptWith(layoutPage.RenderedSections);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unRenderedSections -> unrenderedSections

@rynowak
Copy link
Member

rynowak commented Mar 20, 2015

:shipit:

@ajaybhargavb ajaybhargavb changed the title [Design] Fix for supporting nested sections in layouts Fix for supporting nested sections in layouts Mar 21, 2015
@ajaybhargavb
Copy link
Contributor Author

Updated with tests.

@ajaybhargavb ajaybhargavb merged commit c62974d into dev Mar 22, 2015
@ajaybhargavb ajaybhargavb deleted the fix-nested-layout branch March 22, 2015 00:32
// Verify that RenderBody is called
layoutPage.EnsureBodyWasRendered();

unrenderedSections.UnionWith(layoutPage.PreviousSectionWriters.Keys);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might not address sections that are redefined but not rendered in the outer definition.

// NestedLayout
@{ Layout = "OuterLayout"; }
@section scripts {
   // stuff
}

// OuterLayout
@{ Layout = "BaseLayout"; }
@section scripts { 
  // Don't render inner scripts
}

// BaseLayout
@RenderSection("scripts");

In this scenario, the scripts section defined by NestedLayout is never rendered but the view would happily succeed. Perhaps we shouldn't be flattening the results in unrenderedSections?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants