prettier-plugin-ejs 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -3
- package/index.js +1 -1
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Prettier Plugin for EJS
|
|
2
2
|
|
|
3
|
-
This plugin formats [EJS](https://ejs.co/) markup
|
|
3
|
+
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.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -8,6 +8,54 @@ This plugin formats [EJS](https://ejs.co/) markup as comments in `html` files.
|
|
|
8
8
|
npm install --save-dev prettier-plugin-ejs
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Example
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
### Before
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<div>
|
|
17
|
+
<!-- prettier-ignore -->
|
|
18
|
+
<div>
|
|
19
|
+
<% if (condition) { %> <% } else if (condition) { %> <% } %>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<!-- prettier-ignore -->
|
|
23
|
+
<div>
|
|
24
|
+
<%
|
|
25
|
+
const a = 0;
|
|
26
|
+
%>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<div class="<%= red %>"><%= 1 > 0 %></div>
|
|
30
|
+
<textarea><%= text %></textarea>
|
|
31
|
+
<code><%= text %></code>
|
|
32
|
+
<pre><%= text %></pre>
|
|
33
|
+
</div>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### After
|
|
37
|
+
|
|
38
|
+
```html
|
|
39
|
+
<div>
|
|
40
|
+
<div>
|
|
41
|
+
<% if (condition) { %>
|
|
42
|
+
<% } else if (condition) { %>
|
|
43
|
+
<% } %>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<div>
|
|
47
|
+
<%
|
|
48
|
+
const a = 0;
|
|
49
|
+
%>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<div class="<%= red %>"><%= 1 > 0 %></div>
|
|
53
|
+
<textarea><%= text %></textarea>
|
|
54
|
+
<code><%= text %></code>
|
|
55
|
+
<pre><%= text %></pre>
|
|
56
|
+
</div>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Note
|
|
60
|
+
|
|
61
|
+
Tags which contains the greater then symbol `>` are ignored.
|
package/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var parserHtml = require('prettier/parser-html');
|
|
4
4
|
|
|
5
|
-
const regex =
|
|
5
|
+
const regex = /"[^"]*"|<textarea.*?<\/textarea|(<%([^>]*?)%>)/gs;
|
|
6
6
|
function parse(text, parsers, options) {
|
|
7
7
|
return parserHtml.parsers.html.parse(text.replace(regex, (m, t, c) => (!t ? m : `<?${c}?>`)), parsers, options);
|
|
8
8
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prettier-plugin-ejs",
|
|
3
3
|
"displayName": "Prettier EJS Plugin",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.10",
|
|
5
5
|
"description": "A prettier plugin for Embedded JavaScript Templating.",
|
|
6
6
|
"keywords": [
|
|
7
|
-
"
|
|
7
|
+
"prettier",
|
|
8
8
|
"plugin",
|
|
9
9
|
"ejs",
|
|
10
10
|
"html"
|
|
@@ -25,13 +25,15 @@
|
|
|
25
25
|
"scripts": {
|
|
26
26
|
"clean": "git clean -Xdf",
|
|
27
27
|
"format": "prettier --ignore-path .gitignore --write .",
|
|
28
|
-
"build": "rollup -c"
|
|
28
|
+
"build": "rollup -c",
|
|
29
|
+
"prepack": "npm run clean && npm install && npm run build"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@rollup/plugin-typescript": "^11.0.0",
|
|
32
33
|
"@types/prettier": "^2.7.2",
|
|
33
34
|
"prettier": "^2.8.6",
|
|
34
|
-
"
|
|
35
|
+
"prettier-plugin-ejs": "file:../prettier-plugin-ejs",
|
|
36
|
+
"rollup": "^3.20.1",
|
|
35
37
|
"tslib": "^2.5.0"
|
|
36
38
|
},
|
|
37
39
|
"peerDependencies": {
|