prettier-plugin-ejs 0.0.9 → 0.0.11

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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +51 -3
  3. package/index.js +1 -1
  4. package/package.json +5 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Ecmel Ercan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
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 as comments in `html` files.
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
- ## Warning
11
+ ## Example
12
12
 
13
- Tags which contains the greater then symbol `>` are not formatted.
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 = /<textarea.*?<\/textarea|"[^"]*"|(<%([^>]*?)%>)/gs;
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,7 +1,7 @@
1
1
  {
2
2
  "name": "prettier-plugin-ejs",
3
3
  "displayName": "Prettier EJS Plugin",
4
- "version": "0.0.9",
4
+ "version": "0.0.11",
5
5
  "description": "A prettier plugin for Embedded JavaScript Templating.",
6
6
  "keywords": [
7
7
  "prettier",
@@ -25,16 +25,18 @@
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",
35
+ "prettier-plugin-ejs": "file:../prettier-plugin-ejs",
34
36
  "rollup": "^3.20.1",
35
37
  "tslib": "^2.5.0"
36
38
  },
37
39
  "peerDependencies": {
38
- "prettier": "^2.8.6"
40
+ "prettier": ">= 2.8"
39
41
  }
40
42
  }