@kosatyi/ejs 0.0.106 → 0.0.108
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/README.md +4 -7
- package/bin/bundler.js +21 -9
- package/dist/cjs/browser.js +532 -650
- package/dist/cjs/bundler.js +110 -78
- package/dist/cjs/element.js +28 -63
- package/dist/cjs/index.js +540 -667
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/worker.js +553 -976
- package/dist/esm/browser.js +565 -588
- package/dist/esm/bundler.js +109 -78
- package/dist/esm/element.js +16 -50
- package/dist/esm/index.js +569 -604
- package/dist/esm/worker.js +563 -611
- package/dist/kosatyi-ejs-0.0.107.tgz +0 -0
- package/dist/umd/browser.js +533 -651
- package/dist/umd/browser.js.map +7 -0
- package/dist/umd/browser.min.js +1 -1
- package/dist/umd/browser.min.js.map +7 -0
- package/dist/umd/element.js +28 -63
- package/dist/umd/element.min.js +1 -1
- package/dist/umd/index.js +541 -668
- package/dist/umd/index.min.js +1 -1
- package/dist/umd/worker.js +819 -1242
- package/dist/umd/worker.min.js +1 -3
- package/package.json +80 -71
- package/types/browser.d.ts +10 -0
- package/types/bundler.d.ts +11 -12
- package/types/context.d.ts +96 -0
- package/types/ejs.d.ts +111 -73
- package/types/element.d.ts +9 -0
- package/types/error.d.ts +14 -0
- package/types/global.d.ts +6 -6
- package/types/index.d.ts +16 -0
- package/types/worker.d.ts +31 -0
package/README.md
CHANGED
|
@@ -17,22 +17,19 @@ $ npm install @kosatyi/ejs
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
19
19
|
```js
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
import {configure, helpers, render} from '@kosatyi/ejs'
|
|
22
21
|
// path where templates is located
|
|
23
|
-
|
|
22
|
+
configure({
|
|
24
23
|
path: 'views'
|
|
25
24
|
})
|
|
26
|
-
|
|
27
25
|
// add custom template helper functions
|
|
28
|
-
|
|
26
|
+
helpers({
|
|
29
27
|
ucase(text){
|
|
30
28
|
return String(text).toUpperCase()
|
|
31
29
|
}
|
|
32
30
|
})
|
|
33
|
-
|
|
34
31
|
// load index.ejs template from `views` folder
|
|
35
|
-
|
|
32
|
+
render('page/index',{
|
|
36
33
|
posts:[{
|
|
37
34
|
title:'Post Title',
|
|
38
35
|
content:"<p>post content</p>"
|
package/bin/bundler.js
CHANGED
|
@@ -2,20 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
import argv from 'process.argv'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { bundler } from '../dist/esm/bundler.js'
|
|
6
6
|
|
|
7
7
|
const schema = argv(process.argv.slice(2))
|
|
8
8
|
|
|
9
9
|
const params = schema({
|
|
10
10
|
target: null,
|
|
11
11
|
umd: false,
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
strict: true,
|
|
13
|
+
globals: '',
|
|
14
|
+
precompiled: 'ejsPrecompiled',
|
|
14
15
|
path: 'views',
|
|
15
16
|
extension: 'ejs',
|
|
16
17
|
})
|
|
17
18
|
|
|
18
|
-
if (
|
|
19
|
+
if (params.globals) {
|
|
20
|
+
params.globals = params.globals
|
|
21
|
+
.split(',')
|
|
22
|
+
.map((s) => String(s).trim())
|
|
23
|
+
.filter((s) => s)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!params.target) {
|
|
19
27
|
throw new Error('target is not a string')
|
|
20
28
|
}
|
|
21
29
|
|
|
@@ -25,17 +33,21 @@ const options = {
|
|
|
25
33
|
umd: params.umd,
|
|
26
34
|
}
|
|
27
35
|
|
|
36
|
+
/**
|
|
37
|
+
* @type {EjsConfig}
|
|
38
|
+
*/
|
|
28
39
|
const config = {
|
|
29
|
-
|
|
40
|
+
strict: params.strict,
|
|
30
41
|
path: params.path,
|
|
31
|
-
|
|
42
|
+
precompiled: params.precompiled,
|
|
32
43
|
extension: params.extension,
|
|
44
|
+
globals: params.globals,
|
|
33
45
|
}
|
|
34
46
|
|
|
35
|
-
const
|
|
47
|
+
const bundle = bundler(options, config)
|
|
36
48
|
|
|
37
|
-
await
|
|
49
|
+
await bundle.build()
|
|
38
50
|
|
|
39
51
|
if (params.watch && params.path) {
|
|
40
|
-
await
|
|
52
|
+
await bundle.watch()
|
|
41
53
|
}
|