Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is awkward to use classes containing numbers #335

Open
JohnDowson opened this issue Mar 28, 2022 · 3 comments
Open

It is awkward to use classes containing numbers #335

JohnDowson opened this issue Mar 28, 2022 · 3 comments

Comments

@JohnDowson
Copy link

Notably Bootstrap has alot of classes like mx-4, px-3, gy-2.

@JohnDowson JohnDowson changed the title It is impossible yo use classes containing numbers. It is impossible to use classes containing numbers Mar 29, 2022
@lambda-fairy
Copy link
Owner

Hi @JohnDowson, thanks for the suggestion and PR!

My primary concern with this (and the reason why numbers weren't permitted originally) is that in Rust proper, 0000069 and 69 are considered to be the same number. But if we allow your proposal, then Maud will introduce a distinction between the two. I'm unsure what implications this might have.

In particular:

  1. Does Rust itself guarantee that number literal tokens are passed through unchanged to proc macros? (So that the token 0000069 is not normalized to 69 or anything else.)
  2. What about other tools, like IDEs or code formatters?
  3. Finally, from a user's point of view, would they be confused by this?

Also, consider that there is already an alternative syntax (."mx-4"). See #267.

@lambda-fairy lambda-fairy changed the title It is impossible to use classes containing numbers It is awkward to use classes containing numbers Sep 18, 2022
@puetzp
Copy link
Contributor

puetzp commented Dec 11, 2023

For me this is more of a documentation issue than a matter of usability. However since I hit this problem myself and found this issue to resolve it, the documentation was updated and explains how to use the "alternative syntax" in order to use numbers in class names.
From my point of view the docs are fine now and there is no need to spend (probably) a lot of time to evaluate the implications mentioned above.

@trepidacious
Copy link

I ran into a similar issue with tailwind, so far my preferred approach is to just use class="some-class" or class=(splice). I don't think this is mentioned in the docs but seems to work fine? One thing I did notice is that if I use .class1 .{(splice)} I will get both class1 and the spliced classes in the resulting html, using class="class1" class=(splice) seems to miss out class1?

This way I don't need to think about quoting only the class names that need it. Another advantage is that the vs code tailwind plugin just needs rust files to be added to the list of relevant languages and it will then pick up the class names. If I use the .class-name syntax the plugin needs an experiment regex setting to find class names, and it's pretty tricky to find a regex that covers all the options for Maud classes without also picking up false positives on method calls in normal rust code. Finally it makes the class names a little easier to pick out since they're highlighted as strings.

It's a shame because I do think it's cool to be able to have .class-name, especially where there are only one or two classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants