jcc-express-mvc 1.0.13 → 1.0.15

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.13",
3
+ "version": "1.0.15",
4
4
  "description": "express mvc structure",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -5,14 +5,14 @@ class Template {
5
5
  #directives = {
6
6
  extends: /@extends\((?<extendPath>['"]([^'"]+)['"])\)/,
7
7
  foreach:
8
- /@foreach\((?<loopvariable>[a-zA-Z0-9_-]+) in (?<loopData>[a-zA-Z0-9._-]+)\)(?<loopBody>[\s\S\t\n\r]+?)@endforeach/,
9
- if: /@if\((?<ifData>[a-zA-Z0-9._-]+)\)(?<ifBody>[\s\S]+?)@else(?<elseBody>[\s\S]+?)@endif/,
8
+ /@foreach \s*\((?<loopvariable>[a-zA-Z0-9_-]+) in (?<loopData>[a-zA-Z0-9._-]+)\)(?<loopBody>[\s\S\t\n\r]+?)@endforeach/,
9
+ if: /@if \s*\((?<ifData>[a-zA-Z0-9._-]+)\)(?<ifBody>[\s\S]+?)@else(?<elseBody>[\s\S]+?)@endif/,
10
10
  include: /@include\((?<includePath>['"]([^'"]+)['"])\)/,
11
11
  ternary:
12
- /@ternary\((?<condition>[a-zA-Z0-9_.-]+)\s*\?\s*(?<trueData>[\s\S]+?)\s*:\s*(?<falseData>[\s\S]+?)\)/,
13
- variable: /{{\s*(?<param>[a-zA-Z0-9_.-]+)\S*}}/,
14
- auth: /@auth(?:(\((?<authData>[^)]*)\)))?(?<authBody>[\s\S]*?)@endauth/,
15
- guest: /@guest(?<guestBody>[\s\S]*?)@endguest/,
12
+ /@ternary \S*\((?<condition>[a-zA-Z0-9_.-]+)\s*\?\s*(?<trueData>[\s\S]+?)\s*:\s*(?<falseData>[\s\S]+?)\)/,
13
+ variable: /{{\s*(?<param>(.*?))\s*}}/,
14
+ auth: /@auth\s*(?:(\((?<authData>[^)]*)\)))?(?<authBody>[\s\S]*?)@endauth/,
15
+ guest: /@guest\s*(?<guestBody>[\s\S]*?)@endguest/,
16
16
  };
17
17
 
18
18
  constructor() {
@@ -118,8 +118,8 @@ class Template {
118
118
  new RegExp(
119
119
  Object.values(this.#directives)
120
120
  .map((regex) => `(${regex.source})`)
121
- .join("|")
122
- )
121
+ .join("|"),
122
+ ),
123
123
  );
124
124
  if (!match) return content;
125
125
  switch (true) {
@@ -33,7 +33,7 @@ class Util {
33
33
  if (item.length === 2) {
34
34
  const newLayout = layoutContent.replace(
35
35
  `@yield(${item[0]})`,
36
- item[1].replace(/\"/g, "")
36
+ item[1].replace(/\"/g, ""),
37
37
  );
38
38
  const { beforMatch, afterMatch } = Util.content(content, match);
39
39
  return Util.layout(beforMatch + afterMatch, newLayout);
@@ -42,7 +42,7 @@ class Util {
42
42
  if (sectionContent) {
43
43
  const newLayout = layoutContent.replace(
44
44
  `@yield(${sectionContent})`,
45
- match?.groups?.sectionBody
45
+ match?.groups?.sectionBody,
46
46
  );
47
47
  const { beforMatch, afterMatch } = Util.content(content, match);
48
48
  return Util.layout(beforMatch + afterMatch, newLayout);
@@ -51,7 +51,7 @@ class Util {
51
51
  }
52
52
 
53
53
  static accessNestedProperty(obj, propertyString) {
54
- const properties = propertyString?.split(".") ?? [];
54
+ const properties = propertyString.replace(/\s/g, "")?.split(".") ?? [];
55
55
  return properties.reduce((acc, prop) => acc?.[prop], obj) ?? "";
56
56
  }
57
57