neobiz 4.5.0 → 4.7.2

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/browser.js CHANGED
@@ -11,6 +11,7 @@ let option = {
11
11
  ({}.__proto__.renderOption = (opt) => {
12
12
  option = opt;
13
13
  });
14
+ ({}.__proto__.Null = Symbol("@null"));
14
15
  function renderz(val = {}) {
15
16
  let result = "";
16
17
  let status = option.prefix;
@@ -22,10 +23,12 @@ function renderz(val = {}) {
22
23
  result += renderz({ [e[0]]: g });
23
24
  });
24
25
  } else if (typeof e[1] == "object") {
25
- // if (e[1].noprefix == "true") option.prefix = false;
26
- if (e[1].noprefix) option.prefix = false;
27
- if (e[1].nopAttr) option.prefixAttr = false;
28
- // console.log({ val: e[1], l: e[1].noprefix });
26
+ // const { noprefix = null, nopAttr = null } = e[1];
27
+ e[1].noprefix = e[1].noprefix || false;
28
+ e[1].nopAttr = e[1].nopAttr || false;
29
+ if (e[1].noprefix == "true") option.prefix = false;
30
+ if (e[1].nopAttr == "true") option.prefixAttr = false;
31
+ // if (nopAttr) option.prefixAttr = false;
29
32
 
30
33
  e[0] = e[0].replace(/\s/g, "");
31
34
  if (!option.ignoreTag) {
@@ -38,8 +41,11 @@ function renderz(val = {}) {
38
41
  const temp = [];
39
42
  let inn = "";
40
43
  Object.entries(e[1]).forEach((k) => {
41
- if (
44
+ if (typeof k[1] == "symbol" && k[1].toString() == "Symbol(@null)")
45
+ result += ` ${k[0]}`;
46
+ else if (
42
47
  typeof k[1] != "object" &&
48
+ typeof k[1] != "function" &&
43
49
  k[0] != "text" &&
44
50
  k[0] != "html" &&
45
51
  k[0] != "noprefix" &&
@@ -74,7 +80,7 @@ function renderz(val = {}) {
74
80
  .replace(/&/g, "&")
75
81
  .replace(/</g, "&lt;")
76
82
  .replace(/>/g, "&gt;")
77
- .replace(/"/g, "&quot;")
83
+ // .replace(/"/g, "&quot;")
78
84
  .replace(/'/g, "&#39;")
79
85
  : k[1].toString()
80
86
  }`;
@@ -130,7 +136,7 @@ function renderz(val = {}) {
130
136
  result = result.replace(/[\r\n\t]/gm, "");
131
137
  result = result.replace(/\s{2,}/gm, " ");
132
138
  } catch (e) {
133
- result = `<p>Error: ${e.message}</p>`;
139
+ result = `<p>Error: ${e}</p>`;
134
140
  }
135
141
  option.prefixAttr = status2;
136
142
  option.prefix = status;
@@ -0,0 +1,17 @@
1
+ /** @format */
2
+
3
+ import "../index.js";
4
+ renderOption({
5
+ prefix: "ion-",
6
+ });
7
+ console.log(
8
+ {
9
+ button: {
10
+ text: "Hello World!",
11
+ disabled: Null,
12
+ onclick() {
13
+ alert("hi");
14
+ },
15
+ },
16
+ }._render
17
+ );
package/index.js CHANGED
@@ -7,7 +7,7 @@ function outFile(source, data) {
7
7
  (function () {
8
8
  const dir = path.dirname(path.resolve(source));
9
9
  if (!fs.existsSync(dir)) fs.mkdirSync(dir);
10
- fs.writeFileSync(source, data.render);
10
+ fs.writeFileSync(source, data._render);
11
11
  console.log(`Output file: ${source}`);
12
12
  })();
13
13
  return data.render;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "neobiz",
3
- "version": "4.5.0",
4
- "description": "A simple view engine with JS features",
3
+ "version": "4.7.2",
4
+ "description": "A simple tool to convert Object to HTML string",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
package/readme.md CHANGED
@@ -1,13 +1,20 @@
1
1
  <!-- @format -->
2
2
 
3
- # Documentation Neobiz.js 4.5
3
+ # Documentation Neobiz.js 4.7.x
4
4
 
5
5
  > A simple view engine that has 100% JS features
6
6
 
7
7
  Neobiz.js is pure in JS lang, transform Object into HTML
8
8
 
9
+ fix error `outFIle`
10
+
9
11
  ## Updates:
10
12
 
13
+ - fix event bugs
14
+ - Boolean attributes / non-value attribute (example: disabled, readonly)
15
+
16
+ ## prev update:
17
+
11
18
  - `render` method change to `**\_render**`to avoid conflict with another library and add safety check
12
19
  - render option props improve
13
20
  - fix bug on child order
@@ -84,8 +91,7 @@ const myComponent = {
84
91
 
85
92
  #### Why use this?
86
93
 
87
- - Integrating back-end to view
88
- - **directly** manipulation data or Model with a view
94
+ - Easy maintance innerHTML rather than literal string
89
95
  - Generate static html file
90
96
  - Full control of view. Such as filtering, encrypting the data before serve, or just like conditional and loop case
91
97
  - Almost no need to learn anything. Just need to learn how to render
@@ -149,6 +155,16 @@ properties dom
149
155
  // <h1 class="heading" style="color: #DC1E1E">Hello World!</h1>
150
156
  ```
151
157
 
158
+ boolean attributes
159
+
160
+ use `Null` to indicate non-value attributes, do not confuse `Null` to `null`
161
+
162
+ ```js
163
+ {
164
+ button: { text: "Hello World!", disabled: Null },
165
+ }._render
166
+ ```
167
+
152
168
  innerText & innerHTML:
153
169
 
154
170
  ```js