Skip to content

Instantly share code, notes, and snippets.

@deviationist
Created January 5, 2023 13:04
Show Gist options
  • Select an option

  • Save deviationist/6730a17efeb51f0fdd52e8293f79b1f9 to your computer and use it in GitHub Desktop.

Select an option

Save deviationist/6730a17efeb51f0fdd52e8293f79b1f9 to your computer and use it in GitHub Desktop.
How to print an attribute as a variable in a CSHTML-file.
var ariaCurrent = true ? "aria-current=\"page\"" : "";
<a href="https://foo.bar" @Html.Raw(ariaCurrent)>Foo</a>
var ariaCurrent2 = true ? @"aria-current=""page""" : "";
<a href="https://foo.bar" @Html.Raw(ariaCurrent2)>Foo</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment