prettier-plugin-ejs

1.0.3 • Public • Published

Prettier Plugin for EJS

This plugin formats EJS markup in html files. It uses the default html parser and just marks EJS specific tags as comments.

Installation

npm install --save-dev prettier-plugin-ejs

For Prettier v2, the plugin will be loaded automatically.

For Prettier v3, you'll need to manually load the plugin:

prettier --plugin=prettier-plugin-ejs --write .

Please check Prettier Docs for other loading methods.

Example

Before

<div>
  <!-- prettier-ignore -->
  <div>
    <% if (condition) { %> <% } else if (condition) { %> <% } %>
  </div>

  <div class="<%= red %>"><%= 1 > 0 %></div>

  <textarea><%= text %></textarea>
  <code><%= text %></code>
  <pre><%= text %></pre>
</div>

After

<div>
  <div>
    <% if (condition) { %>
    <% } else if (condition) { %>
    <% } %>
  </div>

  <div class="<%= red %>"><%= 1 > 0 %></div>

  <textarea><%= text %></textarea>
  <code><%= text %></code>
  <pre><%= text %></pre>
</div>

Nested Tag

<td <% if (styleData) { %>
  style="<%= styleData %>" <% } %>>
  <%= data %>
  <%= data %>
</td>

Note

Tags which contains the greater then symbol > are ignored.

Readme

Keywords

Package Sidebar

Install

npm i prettier-plugin-ejs

Weekly Downloads

5,087

Version

1.0.3

License

MIT

Unpacked Size

3.74 kB

Total Files

4

Last publish

Collaborators

  • ecmel