I would like to pass csHtml to a ViewComponent like this:
<vc:some-component title="Title"
body="@Html.Raw("<div>this is a nice div, my name is @Model.Name</div>")">
</vc:some-component>
As you can see, I want to pass HTML that contains references to variables or the model (that's why I'm calling it csHtml and not just Html).
And here is the ViewComponent code:
<div>
<p>@Model.Title</p>
@Model.Content
</div>
Is this even possible? I've been searching and haven't found any examples of how to do this.
Edit: Got it working! Thanks everyone for your help.
Here is some sample code for how to do this:
Calling ViewComponent:
@{
Func<dynamic, object> children =
@<div>
<p style="color: white">aaaa</p>
<p style="color: white">bbbb</p>
<p style="color: white">bbbb</p>
</div>;
}
<vc:some-component body=@children>
</vc:some-component>
View Component content:
@model SomeComponentModel
<div>
@Model.Body("")
</div>
aaaa
bbbb
ccccc