Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ecmel/prettier-plugin-ejs

Prettier EJS Plugin
https://github.com/ecmel/prettier-plugin-ejs

ejs ejs-templates html npm-package prettier

Last synced: 3 months ago
JSON representation

Prettier EJS Plugin

Awesome Lists containing this project

README

        

# Prettier Plugin for EJS

This plugin formats [EJS](https://ejs.co/) markup in `html` files. It uses the default html parser and just marks EJS specific tags as comments.

## Installation

```sh
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:

```sh
prettier --plugin=prettier-plugin-ejs --write .
```

Please check [Prettier Docs](https://prettier.io/docs/en/plugins.html) for other loading methods.

## Example

### Before

```html




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

<%= 1 > 0 %>

<%= text %>
<%= text %>

<%= text %>


```

### After

```html



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

<%= 1 > 0 %>

<%= text %>
<%= text %>

<%= text %>


```

## Nested Tag

```html

style="<%= styleData %>" <% } %>>
<%= data %>
<%= data %>

```

## Note

Tags which contains the greater then symbol `>` are ignored.