Kevon
Kevon

Reputation: 1337

Blazor + conditional HTML Comments

In a Blazor Server app, I'm trying to generate HTML which will be rendered for consumption in an email.

Meaning, the server will generate the full HTML based on a template which I will merge with various bits of data.

One of the things I'd like to do is include some conditional HTML so it renders well in Outlook, some of what I'm trying to do is described here: https://ourcodeworld.com/articles/read/139/all-you-need-to-know-about-conditional-html-comments

When I include any html comments, Blazor's rendering engine ignores them and does not include them in the output.

Is there some way to force Blazor's renderer to include my comments?

Upvotes: 2

Views: 612

Answers (1)

Mister Magoo
Mister Magoo

Reputation: 9029

You need MarkupString

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

or

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

Upvotes: 7

Related Questions