-
Notifications
You must be signed in to change notification settings - Fork 222
Tag Helpers: Change tag and attribute names to be kebab-cased. #262
Conversation
/cc @dougbu or @pranavkm AND @DamianEdwards |
this_is_snake_case. I think you mean kebab-case? But either way, I recommend giving this stuff a more suitable name because none of these terms is particularly common. |
oO yupp, looks like kebab, didn't know about that one 😄. I guess we could just call it HTMLCase? lmao |
Yeah in all seriousness just call it "HtmlAttributeFormat" or whatever. The method name could be "ToHtmlAttributeName" or whatever makes sense. |
ee9136f
to
1111eba
Compare
private const string HtmlCaseRegexReplacement = "-$1$2"; | ||
|
||
private static readonly Regex HtmlCaseRegex = | ||
new Regex("(?<!^)((?<=[a-zA-Z0-9])[A-Z][a-z])|((?<=[a-z])[A-Z])", RegexOptions.None); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
regexes always should come with some documentation - what does this match? what does it not-match? what are the interesting edge cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I'd count myself among the few mortals who understand lookbehind, this definitely deserves some explanation.
Any changes needed to functional tests? |
@rynowak no functional test cases were impacted because Razor's functional tests are half functional tests lol. Real ones are in MVC (added a reaction PR there which addresses them). |
Updated. |
/// </summary> | ||
/// <example> | ||
/// SomeThing => some-thing | ||
/// capsONInside => caps-ON-Inside |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this correct? All of the other examples have NO caps in the output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fail comment is all, it should all be lowercase 👍
|
44c65bb
to
8710944
Compare
8710944
to
8c47f6a
Compare
Tag Helpers: Map PascalCase type & property names to HTML element & attribute dashed equivalents #240