michael melena
michael melena

Reputation: 545

Escaping @ in Blazor

I want to display image from icon library in Blazor component.

The path is:

wwwroot/lib/@icon/open-iconic/icons/account-login.svg

But @ is a special character in Blazor.

Upvotes: 24

Views: 7198

Answers (2)

Gerrit
Gerrit

Reputation: 836

Just add another @ symbol. So your exmaple:

wwwroot/lib/@@icon/open-iconic/icons/account-login.svg

will render as:

wwwroot/lib/@icon/open-iconic/icons/account-login.svg

Upvotes: 16

dani herrera
dani herrera

Reputation: 51715

Quoting Razor syntax:

To escape an @ symbol in Razor markup, use a second @ symbol:

<p>@@Username</p>

The code is rendered in HTML with a single @ symbol:

<p>@Username</p>

Upvotes: 36

Related Questions