question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: formatting ejs creates wrong code

See original GitHub issue

Prettier 1.15.2 Playground link

--parser html

Input:

<html>
	<input <% if(!flag){ %> disabled <%}%> />
</html>

Output:

<html>
  <input <% if(!flag){ % />
  disabled <%}%> />
</html>

Expected behavior: when using prettier before it did not put any / at the end of any > symbol, but now it separates ‘%’ and ‘>’ (they together make ejs closing tag) puts slash before the > symbol, so the ejs file fails to compile!

expected output should be something like this:

<html>
  <input <% if(!flag){ %>
  disabled <%}%> />
</html>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ikatyangcommented, Nov 23, 2018

I think this is probably an VSCode issue since it’s not reproducible via CLI. Can you open an issue in prettier-vscode?

1reaction
ikatyangcommented, Nov 15, 2018

We do not support ejs, and its syntax is conflict with HTML (the first > after <input will be recognized as input’s opening tag end marker in HTML). I have a similar explanation that can also be applied here, see https://github.com/prettier/prettier/issues/5428#issuecomment-437412183.

Read more comments on GitHub >

github_iconTop Results From Across the Web

.ejs formatting in VSCode - Stack Overflow
I know that's an old question, but working with .ejs in VSCode is still a problem. But I found the solution (for ?...
Read more >
Formatting EJS code with 2 spaces indent is not possible
I have an EJS template which I would like to auto-format using 2 spaces for indentation. I setup: File > Settings > Other...
Read more >
EJS -- Embedded JavaScript templates
EJS is a simple templating language that lets you generate HTML markup with plain JavaScript. ... JavaScript code in simple, straightforward scriptlet tags....
Read more >
Common Errors - RequireJS
This page lists errors that are generated by RequireJS. ... Likely causes and fixes: ... It is an error with the code logic...
Read more >
Best Practices for Node.js Error-handling - Toptal
Developers working with Node.js sometimes find themselves writing not-so-clean code while handling all sorts of errors. This article will introduce you to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found