Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/ecmel/prettier-plugin-ejs
- Owner: ecmel
- License: mit
- Created: 2023-03-23T10:19:36.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-29T08:07:47.000Z (12 months ago)
- Last Synced: 2024-10-06T14:09:31.682Z (3 months ago)
- Topics: ejs, ejs-templates, html, npm-package, prettier
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/prettier-plugin-ejs
- Size: 44.9 KB
- Stars: 19
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
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.