@helper. App_Code, YourComponentName.cshtml. :
@using System.Web.Mvc;
@helper Render(
ViewContext context,
string title = "Default title",
Func<object, object> header = null,
Func<object, object> content = null,
Func<object, object> footer = null
)
{
<header class="Component-header">
<h3>@title</h3>
@if (header != null) { @header.DynamicInvoke(context); }
</header>
<div class="Component-content">
@if (content != null) { @content.DynamicInvoke(context); }
</div>
<footer class="Component-footer">
@if (footer != null) { @footer.DynamicInvoke(context); }
</footer>
}
:
@YourComponentName.Render(
ViewContext,
title: "Title",
header: @<p>Markup for the header</p>,
content: @<p>The content</p>,
footer: @<p>Markup for the footer</p>
)