I'm facing a problem with EJS files on VSCode, each time I save the file, the formatter applies a wrong indentation.
Below each EJS identifier the next line is shifted to the right missing the correct vertical alignment.
I'm using HTML format for *.ejs and installed the EJS extension from DigitalBrainstem
<% if(locals.metadata && locals.metadata.length>0) { %>
<% var supplier=metadata[0] %>
<% } %>
<main class="site-content">
Another example in the picture below
You can see in the both examples, it looks like a ladder, each line is automatically indented to the right and cannot keep opening/closure code blocks aligned.
Just was looking for the solution to this myself. If installing the ESJ language support plugin didn't work on its own. Go to the settings and search for Format: templating
you'll see the option to honor some templating language tags. Activate it. This worked for me at least.
I found the solution:
EJS language support
plugin<? for( let item of array ) { ?>
(some data)
<? } ?>
are formatted incorrectly (at least with default html formatter).
ejs.delimeter = '?'
. Now you have correct indentation.Snippets Ranger
plugin, then find needed extension and edit its file. The Snippets Ranger
is very handy tool.I hope I helped somebody to setup VSCode for .ejs files
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With