jcc-express-mvc 1.0.12 → 1.0.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jcc-express-mvc",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "express mvc structure",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -11,7 +11,7 @@ class Template {
11
11
  ternary:
12
12
  /@ternary\((?<condition>[a-zA-Z0-9_.-]+)\s*\?\s*(?<trueData>[\s\S]+?)\s*:\s*(?<falseData>[\s\S]+?)\)/,
13
13
  variable: /{{\s*(?<param>[a-zA-Z0-9_.-]+)\S*}}/,
14
- auth: /@auth(?<authBody>[\s\S]*?)@endauth/,
14
+ auth: /@auth(?:(\((?<authData>[^)]*)\)))?(?<authBody>[\s\S]*?)@endauth/,
15
15
  guest: /@guest(?<guestBody>[\s\S]*?)@endguest/,
16
16
  };
17
17
 
@@ -122,31 +122,36 @@ class Template {
122
122
  )
123
123
  );
124
124
  if (!match) return content;
125
+ switch (true) {
126
+ case match[0].startsWith("@include"):
127
+ return this.#includes(content, match, param);
125
128
 
126
- if (match[0].startsWith("@include")) {
127
- return this.#includes(content, match, param);
128
- }
129
- if (match[0].startsWith("@foreach")) {
130
- return this.#handleLoop(content, match, param);
131
- }
132
- if (match[0].startsWith("@auth")) {
133
- return this.#auth(content, match, param);
134
- }
135
- if (match[0].startsWith("@guest")) {
136
- return this.#guest(content, match, param);
137
- }
138
- if (match[0].startsWith("@if")) {
139
- return this.#handleCondition(content, match, param);
140
- }
141
- if (match[0].startsWith("@ternary")) {
142
- return this.#ternary(content, match, param);
143
- }
129
+ case match[0].startsWith("@foreach"):
130
+ return this.#handleLoop(content, match, param);
131
+
132
+ case match[0].startsWith("@auth"):
133
+ return this.#auth(content, match, param);
144
134
 
145
- return this.#handleVariable(content, match, param);
135
+ case match[0].startsWith("@guest"):
136
+ return this.#guest(content, match, param);
137
+
138
+ case match[0].startsWith("@if"):
139
+ return this.#handleCondition(content, match, param);
140
+
141
+ case match[0].startsWith("@ternary"):
142
+ return this.#ternary(content, match, param);
143
+
144
+ case match[0].startsWith("{{"):
145
+ return this.#handleVariable(content, match, param);
146
+ default:
147
+ return content;
148
+ }
146
149
  }
147
150
 
148
151
  #compiler(content) {
149
- const newContent = this.#extends(content);
152
+ const newContent = this.#extends(content)
153
+ .replace(/(\{\{\-\-)/g, "<!--")
154
+ .replace(/(\-\-\}\})/g, "-->");
150
155
  const finalContent = this.#parser(newContent);
151
156
  return finalContent
152
157
  .replace(/(\{\{\-\-)/g, "<!--")