neobiz 3.3.0 → 3.8.1
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 +5 -3
- package/example/style.v.js +28 -0
- package/package.json +4 -2
- package/readme.md +65 -5
package/browser.js
CHANGED
|
@@ -235,9 +235,11 @@ Object.defineProperty({}.__proto__, "cssText", {
|
|
|
235
235
|
return y;
|
|
236
236
|
},
|
|
237
237
|
});
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
238
|
+
|
|
239
|
+
Object.defineProperty({}.__proto__, "alter", {
|
|
240
|
+
value: function (fn) {
|
|
241
|
+
fn(this);
|
|
242
|
+
return this;
|
|
241
243
|
},
|
|
242
244
|
});
|
|
243
245
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** @format */
|
|
2
|
+
|
|
3
|
+
import "../index.js";
|
|
4
|
+
|
|
5
|
+
// inline
|
|
6
|
+
console.log(
|
|
7
|
+
{
|
|
8
|
+
h1: {
|
|
9
|
+
text: "this is text",
|
|
10
|
+
style: { color: "blue", fontSize: "140%" }.cssText,
|
|
11
|
+
},
|
|
12
|
+
}.render
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
// tag style
|
|
16
|
+
console.log(
|
|
17
|
+
{
|
|
18
|
+
style: {
|
|
19
|
+
h1: {
|
|
20
|
+
// something
|
|
21
|
+
},
|
|
22
|
+
body: {
|
|
23
|
+
margin: "0px",
|
|
24
|
+
padding: "0px",
|
|
25
|
+
},
|
|
26
|
+
}.css,
|
|
27
|
+
}.render
|
|
28
|
+
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neobiz",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.1",
|
|
4
4
|
"description": "A simple view engine with JS features",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
"template",
|
|
12
12
|
"dom",
|
|
13
13
|
"html",
|
|
14
|
-
"express"
|
|
14
|
+
"express",
|
|
15
|
+
"front-end",
|
|
16
|
+
"layout"
|
|
15
17
|
],
|
|
16
18
|
"license": "MIT"
|
|
17
19
|
}
|
package/readme.md
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
<!-- @format -->
|
|
2
2
|
|
|
3
|
-
# Documentation Neobiz.js 3.
|
|
3
|
+
# Documentation Neobiz.js 3.8
|
|
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
|
+
new features:
|
|
10
|
+
|
|
11
|
+
- add eventHandler
|
|
12
|
+
- style/css
|
|
13
|
+
- altering object
|
|
14
|
+
|
|
9
15
|
`read /example dir to understanding`
|
|
10
16
|
|
|
11
17
|
[link to usage in express.js](https://www.npmjs.com/package/neobiz-express?activeTab=dependencies)
|
|
@@ -29,7 +35,7 @@ import "neobiz";
|
|
|
29
35
|
id: "app",
|
|
30
36
|
},
|
|
31
37
|
script: {
|
|
32
|
-
html
|
|
38
|
+
html() {
|
|
33
39
|
const { createApp } = Vue;
|
|
34
40
|
|
|
35
41
|
createApp(myComponent).mount("#app");
|
|
@@ -54,11 +60,12 @@ const myComponent = {
|
|
|
54
60
|
| properties | caller | return-type | description |
|
|
55
61
|
| ---------- | ------------------------------------- | ----------- | -------------------------------- |
|
|
56
62
|
| render | Object | string | rendering to HTML |
|
|
57
|
-
| outFile | Object @params[
|
|
63
|
+
| outFile | Object @params destination[string] | void | generate static HTML file |
|
|
58
64
|
| range | Array @params length[int], start[int] | Array | shortcut for looping in a range |
|
|
59
65
|
| repulse | String | Object | generate object from HTML string |
|
|
60
66
|
| css | Object | Object | generate css from object |
|
|
61
|
-
| cssText | Object |
|
|
67
|
+
| cssText | Object | Object | inline css |
|
|
68
|
+
| alter | Object @params cb[function] | Object | altering object before rendering |
|
|
62
69
|
|
|
63
70
|
#### Why use this?
|
|
64
71
|
|
|
@@ -198,6 +205,22 @@ Can't use array? just use this:
|
|
|
198
205
|
}
|
|
199
206
|
```
|
|
200
207
|
|
|
208
|
+
### Modify an Object
|
|
209
|
+
|
|
210
|
+
use `alter` properties, with function as params. no need to return a value
|
|
211
|
+
|
|
212
|
+
```js
|
|
213
|
+
const y = {
|
|
214
|
+
h1: { text: "Hello World!" },
|
|
215
|
+
p: { text: "this is a p" }.alter((e) => (e.class = "lorem")),
|
|
216
|
+
}.alter((e) => {
|
|
217
|
+
e.h1.text = "thi is altered text";
|
|
218
|
+
e.h1.style = { color: "red", fontSize: "150%" }.cssText;
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
console.log(y.render);
|
|
222
|
+
```
|
|
223
|
+
|
|
201
224
|
### Components / Partials
|
|
202
225
|
|
|
203
226
|
```js
|
|
@@ -279,6 +302,27 @@ style.body.margin = "12px";
|
|
|
279
302
|
}.render
|
|
280
303
|
```
|
|
281
304
|
|
|
305
|
+
reusable style / mixin
|
|
306
|
+
|
|
307
|
+
```js
|
|
308
|
+
const flex = (justify, align, direction = "row") => ({
|
|
309
|
+
display: "flex",
|
|
310
|
+
justifyContent: justify,
|
|
311
|
+
alignItems: align,
|
|
312
|
+
flexDirection: direction,
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
const space = {
|
|
316
|
+
padding: "6px 8px",
|
|
317
|
+
margin: "6px 10px",
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
console.log({
|
|
321
|
+
style: { div: flex("center", "center"), button: { border: "none", ...space } }
|
|
322
|
+
.css,
|
|
323
|
+
});
|
|
324
|
+
```
|
|
325
|
+
|
|
282
326
|
### Interacting with DOM
|
|
283
327
|
|
|
284
328
|
use `script` to interact with browser with **html** property
|
|
@@ -354,7 +398,7 @@ result
|
|
|
354
398
|
|
|
355
399
|
## Pass Value
|
|
356
400
|
|
|
357
|
-
use function
|
|
401
|
+
use shorthand anonym function
|
|
358
402
|
|
|
359
403
|
```js
|
|
360
404
|
console.log(((user) => ({ h1: { text: `Hello, ${user}` } }))("Vins").render);
|
|
@@ -398,6 +442,22 @@ IIFE if-else
|
|
|
398
442
|
}
|
|
399
443
|
```
|
|
400
444
|
|
|
445
|
+
normal if else
|
|
446
|
+
|
|
447
|
+
```js
|
|
448
|
+
let result;
|
|
449
|
+
if (status) result = { text: "Hello World!" };
|
|
450
|
+
else
|
|
451
|
+
result = {
|
|
452
|
+
a: { href: "#", text: "You are offline!" },
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
//use
|
|
456
|
+
{
|
|
457
|
+
h1: result,
|
|
458
|
+
}
|
|
459
|
+
```
|
|
460
|
+
|
|
401
461
|
IIFE switch-case
|
|
402
462
|
|
|
403
463
|
```js
|