What I'm looking for is a nicer more declarative approach to Templated Razor Delegates
In Any old Razor Page or View - SomePage.cshtml
...
<div>
<partial name="Shared/_PartialLayout" for="SomeModel">
<strong>Content</strong> that will be injected into the layout, which
will get rendered here.
</partial>
</div>
...
In _PartialLayout.cshtml
<div class="stuff">
<h2>@Model.SubTitle</h2>
<div class="passed-in-content">
@RenderContent()
</div>
</div>
And the rendered result
...
<div>
<div class="stuff">
<h2>@Model.SubTitle</h2>
<div class="passed-in-content">
<strong>Content</strong> that will be injected into the layout, which
will get rendered here.
</div>
</div>
</div>
...
The actual problem domain is I want to create reusable dialogs. I'm making use of this web component: https://github.com/github/details-dialog-element. But there's a lot of boilerplate to use it in a real app. My quick and dirty solution is to put much of that boilerplate in a layout, then create a partial per dialog invocation. The latter part is a pain.
DialogLayout.cshtml
ChangeUsernameDialog.cshtml
Then when I need to invoke this.
Lots of little challenges here. For example, this partial contains a form that posts to its containing page. So any solution needs to make that easy.