-
-
Notifications
You must be signed in to change notification settings - Fork 44
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: Can't interpolate Pug variables into a Vue directive #238
Comments
Okay, I think the issue is somewhere around here Lines 871 to 875 in 931fe36
So I already try to detect multiline strings that uses backticks Then it checks for So I think the best we can do here is to introduce a new if-else branch on line 873 (so between Then we need to find a good solution to format such code (or ignore formatting at all like with the multiline ones) |
Please review https://github.com/prettier/plugin-pug/pull/239/files And you can do me also a favor if you could check this branch out, use yarn link and test it with your local project in real world scenario I'm a little bit afraid, that I just disabled to much so that things that potentially formatted previously doesn't format now anymore 🤔 So currently it's just: if surrounded by backticks and include |
Thank you very much, I'm happy to review and test locally but I won't be available until Sunday or Monday. As for a solution, it would be amazing for my use case to format for example :class=`{'foo':${foo}}` as :class=`{ 'foo': ${foo} }` but i would not be surprised if that isn't feasible |
Ah damned, that's not possible 🙁 {'foo':${foo}}
^~~~~~ Unexpected token So it would assume it is json in js but then suddenly see a dollar sign where a dollar sign is not possible cause it expected e.g a string, number, other primitive or object/array |
This will land in the upcoming release, but this could take some days and I think I will first create a beta with some other current PRs |
Please try out the new beta v1.16.0-0 and report anything back 🙂 |
Much better, thank you! My Pug has never been so pretty 😄 Sorry about testing, I didn't get a linked version working on the first try and didn't have time to troubleshoot it. And BTW I have had some other problems that break my code. I may open some issues and feel free to close them if out of scope, in the meantime I'm using |
Info
Prettier config
Input
Output or Error
Additional Context
I am using Pug mixins to abstract the template for my Vue app. The mixins use template string interpolation to dynamically render Vue directives in the HTML, and then the HTML becomes the template for mounting the Vue app.
The template strings cause the plugin to error. The error only happens with Vue directives. For other attributes the template strings work fine.
The text was updated successfully, but these errors were encountered: