Blazor + 条件 HTML 评论

Blazor + conditional HTML Comments

在 Blazor Server 应用程序中,我正在尝试生成 HTML,它将在电子邮件中呈现以供使用。

意思是,服务器将根据我将与各种数据位合并的模板生成完整的 HTML。

我想做的一件事是包含一些条件 HTML 以便它在 Outlook 中呈现得很好,这里描述了我正在尝试做的一些事情:https://ourcodeworld.com/articles/read/139/all-you-need-to-know-about-conditional-html-comments

当我包含任何 html 注释时,Blazor 的渲染引擎会忽略它们并且不会将它们包含在输出中。

有什么方法可以强制 Blazor 的渲染器包含我的评论吗?

您需要 MarkupString

@((MarkupString)"<!-- test -->")

@code
{
    MarkupString comment = new MarkupString("<!-- test2 -->");
}
@comment