You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP

prettier-plugin-ejs

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettier-plugin-ejs

A Prettier plugin for Embedded JavaScript Templating (EJS).

1.0.3
latest
Version published
Weekly downloads
5.5K
7.77%
Maintainers
1
Weekly downloads
 
Created

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.

FAQs

Package last updated on 20 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts