Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

Tag Helpers: Change tag and attribute names to be kebab-cased. #262

Merged
merged 2 commits into from
Jan 14, 2015

Conversation

NTaylorMullen
Copy link

@NTaylorMullen
Copy link
Author

/cc @dougbu or @pranavkm AND @DamianEdwards

@Eilon
Copy link
Contributor

Eilon commented Dec 23, 2014

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.

@NTaylorMullen
Copy link
Author

oO yupp, looks like kebab, didn't know about that one 😄. I guess we could just call it HTMLCase? lmao

@Eilon
Copy link
Contributor

Eilon commented Dec 24, 2014

Yeah in all seriousness just call it "HtmlAttributeFormat" or whatever. The method name could be "ToHtmlAttributeName" or whatever makes sense.

@NTaylorMullen NTaylorMullen changed the title Tag Helpers: Change tag and attribute names to be lower snake cased. Tag Helpers: Change tag and attribute names to be HTML cased. Dec 29, 2014
@NTaylorMullen NTaylorMullen changed the title Tag Helpers: Change tag and attribute names to be HTML cased. Tag Helpers: Change tag and attribute names to be kebab-cased cased. Dec 29, 2014
@NTaylorMullen NTaylorMullen changed the title Tag Helpers: Change tag and attribute names to be kebab-cased cased. Tag Helpers: Change tag and attribute names to be kebab-cased. Dec 29, 2014
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);
Copy link
Member

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.

Copy link
Member

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.

@rynowak
Copy link
Member

rynowak commented Dec 29, 2014

Any changes needed to functional tests?

@NTaylorMullen
Copy link
Author

@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).

@NTaylorMullen
Copy link
Author

Updated.

/// </summary>
/// <example>
/// SomeThing => some-thing
/// capsONInside => caps-ON-Inside
Copy link
Member

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

Copy link
Author

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 👍

@rynowak
Copy link
Member

rynowak commented Dec 31, 2014

:shipit: from me

N. Taylor Mullen added 2 commits January 13, 2015 22:51
- Lower kebab casing is the HTML convention.

#240
- Also added additional tests to validate new lower kebab casing.

#240
@NTaylorMullen NTaylorMullen merged commit 8c47f6a into dev Jan 14, 2015
@NTaylorMullen NTaylorMullen deleted the thpascalcase.240 branch January 14, 2015 07:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants