HTML and ejs Tags Messed Up After Save

Viewed 70

I am pretty new to coding and learning templating at the moment. I am having trouble with html and ejs tags auto formatting after save.

As you can see in the images below (sorry, cannot embed images on the post yet since I am new here), html and ejs tags get separated after saving the file and it looks ugly. How can I prevent them from separating?

Saving also auto-indents codes after ejs tags... I want to use format on save, but don't want the indentation.

'Files:Associations' setting already has '*.ejs - html'. 'Emmet: Include Languages' setting also has 'ejs - html'. 'Editor: Default Formatter' is set to None. Extensions I have are 'EditorConfig for VS Code' and 'EJS language support'

Code Before Save:

<body>
    <div class="container">
        <h1>Browsing The <%= name %> subreddit</h1>
        <h2><%= description %></h2>
        <p><%= subscribers %> Total Subscribers</p>
        <hr>
        
        <% for(let post of posts) { %>
            <article>
                <p><%= post.title %> - <b><%=post.author %></b></p>
                <% if(post.img) { %>
                    <img src="<%= post.img %>" alt="">
                    <% } %>
            </article>
            <% } %>
    </div>
</body>

Code After Save: (for example, the bold tag looks out of place and I also want p and b tags in one line along with the ejs tags)

<body>
    <div class="container">
        <h1>Browsing The <%= name %> subreddit</h1>
        <h2>
            <%= description %>
        </h2>
        <p>
            <%= subscribers %> Total Subscribers
        </p>
        <hr>

        <% for(let post of posts) { %>
            <article>
                <p>
                    <%= post.title %> - <b>
                            <%=post.author %>
                        </b>
                </p>
                <% if(post.img) { %>
                    <img src="<%= post.img %>" alt="">
                    <% } %>
            </article>
            <% } %>
    </div>
</body>

Indentation on Save - After ejs Tags

<%- include('partials/head') %>
  <%- include('partials/head') %>

    <body>
      <%- include('partials/navbar') %>

        <h1>Your random number is: <%= num %>
        </h1>

        <% if (num % 2===0) { %>
          <h2>That is an even number!</h2>
          <% } else { %>
            <h2>That is an odd number!</h2>
            <% } %>
              <h3>
                <%= num % 2===0 ? 'Even' : 'Odd' %>
              </h3>
    </body>

    </html>

BeforeSave

AfterSave

Files: Associations setting

Emmet: Include Languages

0 Answers
Related