You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 19, 2018. It is now read-only.
@{ var pwnt = "Hello, world!"; }
<p data-th-color="color: red; @pwnt">
This should be red.
</p>
[TargetElement("p", Attributes = "data-th-color")]
public class ColorTagHelper : TagHelper
{
[HtmlAttributeName("data-th-color")]
public string Color { get; set; }
public override void Process(TagHelperContext context, TagHelperOutput output)
{
output.Attributes.Add("style", Color);
}
}
Inside the taghelper, the value of Color is "Hello, world!" instead of the expected "color: red; Hello, world!". According to @NTaylorMullen this is because razor has special handling of data-* attributes.
Changing the attribute to something that doesn't begin with data- will give the expected behavior.