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

Proc macro panic when class name contains numbers #98

Closed
Arcterus opened this issue Aug 11, 2017 · 7 comments
Closed

Proc macro panic when class name contains numbers #98

Arcterus opened this issue Aug 11, 2017 · 7 comments

Comments

@Arcterus
Copy link

More specifically, panics occur when using dot notation for classes such as the following:

.is-4by3
.is-3

Here's an example function that triggers the panic:

fn test() {
   let _ = html! { figure .is-4by3 { } };
}
@lambda-fairy
Copy link
Owner

I think this is because Maud expects an identifier token there, but sees a number literal instead. (The input 4by3 is parsed as the number 4 with a by3 type suffix.)

The fix, then, would be to accept number literals as well as identifiers as part of a class or ID name.
Note that we'll need to be careful with float literals, otherwise #2.3 would expand to class="2.3" instead of id="2" class="3" as we'd expect. I'll be happy to accept a PR for this.

@albe-rosado
Copy link

albe-rosado commented Oct 8, 2017

shouldn't classes and ids be separated by a space (ie. #2 .3)? there is no way you could know which one is right class="2.3" or class="2" id="3".

@bb010g
Copy link
Contributor

bb010g commented Oct 8, 2017

I'd think it would be simpler to just have complex strings like that require quoting, like figure .'is-4by3' { }.

@albe-rosado
Copy link

I like that, @lfairy what do you think?

@lambda-fairy
Copy link
Owner

Yeah that's a good point. I'll be happy with @bb010g's solution (assuming you meant ."is-4by3", since single quotes won't parse)

@albe-rosado
Copy link

yeah that makes sense and looks nice

@lambda-fairy
Copy link
Owner

Closing in favor of #128, which includes this feature (and more).

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

No branches or pull requests

4 participants