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
Bug: coffee code as html attribute value #26
Comments
The problem here is that attributes are separated by a comma and the attribute regexp sees your attribute value as I have spent almost two days for these 8 lines of code (most time used to read Mastering Regular Expressions) and I'm unable to provide a solution for this. If you are a regexp expert, feel free to send a pull request. You can work around this by simply using string interpolation: %a{ href: "#{ [1,2].join() }" } OMG I know this is not that elegant, but there is currently no other way to do it within the attribute itself. You could also define a function and call it within the attribute. I'll update the docs to be more specific on this. |
Why do you parse the content of
I know that there might be overhead with different styles of attributes representation you support. But this might be the way out for current case. |
Depending on the compiler setting, the attributes are further processed:
|
Yes, I understand that, but unfortunately there is no way to make it work in all cases with regexp parser. %div{ class: "#{ [@one, @two].join(" ") }" } OMG And these edge cases may last forever, because programming code is recursive grammar and it can not be parsed with regexp. Several ways I see now to fix the problem:
Take a look at https://github.com/visionmedia/jade - it's client side templating pretty similar to haml-coffee. They solved this problem somehow. Probably it can help. |
Even when your example can be re-written as %div{ class: "#{ [@one, @two].join(' ') }" } OMG , you're completely right: the pure regexp key value parsing will never be that robust. You made good points, however
In the end I simply moved some logic from the regexp to the code, as your third option :P |
Great job, thanks. |
Template code
%a{href: [1,2].join()} OMG
The text was updated successfully, but these errors were encountered: