Q:

Passing HTML to Custom Tag Helper

I have an MVC Tag Helper which renders a link and some HTML. The HTML could be an icon, for example, or another block of HTML. I'm having trouble converting it to Core. In MVC I used (simplified):
    @RenderTile(Url.Action("SomeAction", "Account"), @<span><i class="fa fa-user"></i> Users</span>)

Then the helper renders the HTML passed as a parameter. It seems the HelperResult class is missing from Core. Is there an alternative?
@helper RenderTile(string url, Func<dynamic, HelperResult> text)
{
    <div class="col-xs-6 col-md-3">
        <a class="tile-link" href="@url" @(newWindow?"target=blank":string.Empty)>
            <div class="text-info tile" style="background: @backgroundColor">

                <div class="row margin-top-20">
                    <div class="col-xs-12 text-center">
                        <div class="tile-text">
                            @text(null)
                        </div>
                    </div>
                </div>
            </div>
        </a>
    </div>
}

A:

To achieve your requirement, you can refer to the following code snippet to author a tag helper.
public class RenderTile: TagHelper
{
    public string Url { get; set; }
    public bool NewWindow { get; set; }
    public string BackgroundColor { get; set; }
    public string text { get; set; }

    public override void Process(TagHelperContext context, TagHelperOutput output)
    {
        output.TagName = "a";    

        output.Attributes.SetAttribute("class", "tile-link");

        if (NewWindow)
        {
            output.Attributes.SetAttribute("target", "_blank");
        }

        output.Attributes.SetAttribute("href", Url);

        output.Content.AppendHtml($@"<div class=""text-info tile"" style=""background: {BackgroundColor}""><div class=""row margin-top-20""><div class=""col-xs-12 text-center""> <div class=""tile-text"">{text}</div></div></div></div>");           
    }
}

In View page
<div class="col-xs-6 col-md-3">
    <render-tile Url="@Url.Action("Privacy", "Home")" new-window="true" background-color="red" 
                 text="<span><i class='fa fa-user'></i>Users</span>">
    </render-tile>
</div>

Test Result

