neobiz 4.1.15 → 4.3.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.
- package/browser.js +16 -2
- package/package.json +2 -1
- package/readme.md +65 -15
package/browser.js
CHANGED
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
"use strict";
|
|
4
4
|
|
|
5
5
|
const adp = {};
|
|
6
|
-
|
|
6
|
+
let d = render ? "_render" : "render";
|
|
7
|
+
let option = {
|
|
8
|
+
camelCase: false,
|
|
9
|
+
};
|
|
10
|
+
({}.__proto__.renderOption = (opt) => {
|
|
11
|
+
option = opt;
|
|
12
|
+
});
|
|
7
13
|
function render(val = {}) {
|
|
8
14
|
let result = "";
|
|
9
15
|
try {
|
|
@@ -16,6 +22,8 @@ function render(val = {}) {
|
|
|
16
22
|
e[0] = e[0].replace(/\s/g, "");
|
|
17
23
|
e[0] = e[1].tag || e[0];
|
|
18
24
|
delete e[1].tag;
|
|
25
|
+
if (option.camelCase)
|
|
26
|
+
e[0] = e[0].replace(/[A-Z]/g, (m) => "-" + m.toLowerCase());
|
|
19
27
|
result += `<${e[0]}`;
|
|
20
28
|
const temp = [];
|
|
21
29
|
let inn = "";
|
|
@@ -105,6 +113,10 @@ function rdr(val = {}) {
|
|
|
105
113
|
result += render(value);
|
|
106
114
|
});
|
|
107
115
|
} else result = render(val);
|
|
116
|
+
if (option.once)
|
|
117
|
+
option = {
|
|
118
|
+
camelCase: false,
|
|
119
|
+
};
|
|
108
120
|
return result;
|
|
109
121
|
}
|
|
110
122
|
function range(length, start = 0) {
|
|
@@ -207,7 +219,9 @@ function fromStr(letter, prefix = 0) {
|
|
|
207
219
|
return temp;
|
|
208
220
|
}
|
|
209
221
|
|
|
210
|
-
|
|
222
|
+
console.log(d);
|
|
223
|
+
|
|
224
|
+
Object.defineProperty({}.__proto__, d, {
|
|
211
225
|
get: function () {
|
|
212
226
|
return "<!DOCTYPE html>" + rdr(this);
|
|
213
227
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neobiz",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.11",
|
|
4
4
|
"description": "A simple view engine with JS features",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"html",
|
|
14
14
|
"express",
|
|
15
15
|
"front-end",
|
|
16
|
+
"frontEnd",
|
|
16
17
|
"layout"
|
|
17
18
|
],
|
|
18
19
|
"license": "MIT"
|
package/readme.md
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
<!-- @format -->
|
|
2
2
|
|
|
3
|
-
# Documentation Neobiz.js 4.
|
|
3
|
+
# Documentation Neobiz.js 4.3.11
|
|
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
|
-
|
|
9
|
+
## Updates:
|
|
10
|
+
|
|
11
|
+
- `render` method will rename to `**\_render**` if there is already exist render method, to avoid conflict with another script
|
|
12
|
+
- render option props
|
|
13
|
+
|
|
14
|
+
New features:
|
|
10
15
|
|
|
11
16
|
- Sanitized eventHandler
|
|
12
17
|
- Reusable & editable style/css
|
|
@@ -61,19 +66,20 @@ const myComponent = {
|
|
|
61
66
|
|
|
62
67
|
<br>
|
|
63
68
|
|
|
64
|
-
| properties
|
|
65
|
-
|
|
|
66
|
-
| render
|
|
67
|
-
| outFile
|
|
68
|
-
| range
|
|
69
|
-
| repulse
|
|
70
|
-
| css
|
|
71
|
-
| cssText
|
|
72
|
-
| alter [trials]
|
|
73
|
-
| reg
|
|
74
|
-
| regm
|
|
75
|
-
| load
|
|
76
|
-
| unred
|
|
69
|
+
| properties | caller | return-type | description |
|
|
70
|
+
| ----------------- | ------------------------------------- | ----------- | --------------------------------------- |
|
|
71
|
+
| render / \_render | Object | string | rendering to HTML |
|
|
72
|
+
| outFile | Object @params destination[string] | void | generate static HTML file |
|
|
73
|
+
| range | Array @params length[int], start[int] | Array | shortcut for looping in a range |
|
|
74
|
+
| repulse | String | Object | generate object from HTML string |
|
|
75
|
+
| css | Object | Object | generate css from object |
|
|
76
|
+
| cssText | Object | Object | inline css |
|
|
77
|
+
| alter [trials] | Object @params cb[function] | Object | altering object before rendering |
|
|
78
|
+
| reg | Object | void | registring an object |
|
|
79
|
+
| regm | Object | void | updating the existing registered object |
|
|
80
|
+
| load | Object | Object | read an existing registered object |
|
|
81
|
+
| unred | Object | void | removing an existing registered object |
|
|
82
|
+
| renderOption | Object @params option[Object] | void | set the option for rendering |
|
|
77
83
|
|
|
78
84
|
#### Why use this?
|
|
79
85
|
|
|
@@ -104,6 +110,17 @@ It's just an Object! `wrap in () to create a statement or just assign to a var`
|
|
|
104
110
|
// <h1>Hello World!</h1>
|
|
105
111
|
```
|
|
106
112
|
|
|
113
|
+
or use call method
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
render.call({
|
|
117
|
+
// text property is same as innerText
|
|
118
|
+
h1: {
|
|
119
|
+
text: "Hello World!",
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
107
124
|
Comments:
|
|
108
125
|
|
|
109
126
|
```js
|
|
@@ -190,6 +207,39 @@ Object can not use 2 keys with the same name
|
|
|
190
207
|
}
|
|
191
208
|
```
|
|
192
209
|
|
|
210
|
+
## Render Option
|
|
211
|
+
|
|
212
|
+
```js
|
|
213
|
+
renderOption({
|
|
214
|
+
camelCase: false,
|
|
215
|
+
once: false,
|
|
216
|
+
});
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
set once to `true` to use option only for once,
|
|
220
|
+
<br>
|
|
221
|
+
<br>
|
|
222
|
+
|
|
223
|
+
set `camelCase` `true` to convert **camelCase** properties to **kebab-case**
|
|
224
|
+
|
|
225
|
+
make sure to set the option before rendering
|
|
226
|
+
|
|
227
|
+
```js
|
|
228
|
+
renderOption({
|
|
229
|
+
camelCase: true,
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
render.call({
|
|
233
|
+
ionRouter: {},
|
|
234
|
+
});
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
result
|
|
238
|
+
|
|
239
|
+
```html
|
|
240
|
+
<ion-router></ion-router>
|
|
241
|
+
```
|
|
242
|
+
|
|
193
243
|
## Explicit tag name
|
|
194
244
|
|
|
195
245
|
What if there is somethings in the middle of list?
|