neobiz 4.5.0 → 4.7.0

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" &&
@@ -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/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.0",
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,6 +1,6 @@
1
1
  <!-- @format -->
2
2
 
3
- # Documentation Neobiz.js 4.5
3
+ # Documentation Neobiz.js 4.7
4
4
 
5
5
  > A simple view engine that has 100% JS features
6
6
 
@@ -8,6 +8,11 @@ Neobiz.js is pure in JS lang, transform Object into HTML
8
8
 
9
9
  ## Updates:
10
10
 
11
+ - fix event bugs
12
+ - Boolean attributes / non-value attribute (example: disabled, readonly)
13
+
14
+ ## prev update:
15
+
11
16
  - `render` method change to `**\_render**`to avoid conflict with another library and add safety check
12
17
  - render option props improve
13
18
  - fix bug on child order
@@ -84,8 +89,7 @@ const myComponent = {
84
89
 
85
90
  #### Why use this?
86
91
 
87
- - Integrating back-end to view
88
- - **directly** manipulation data or Model with a view
92
+ - Easy maintance innerHTML rather than literal string
89
93
  - Generate static html file
90
94
  - Full control of view. Such as filtering, encrypting the data before serve, or just like conditional and loop case
91
95
  - Almost no need to learn anything. Just need to learn how to render
@@ -149,6 +153,16 @@ properties dom
149
153
  // <h1 class="heading" style="color: #DC1E1E">Hello World!</h1>
150
154
  ```
151
155
 
156
+ boolean attributes
157
+
158
+ use `Null` to indicate non-value attributes, do not confuse `Null` to `null`
159
+
160
+ ```js
161
+ {
162
+ button: { text: "Hello World!", disabled: Null },
163
+ }._render
164
+ ```
165
+
152
166
  innerText & innerHTML:
153
167
 
154
168
  ```js