@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 CHANGED
@@ -17,22 +17,19 @@ $ npm install @kosatyi/ejs
17
17
  ## Usage
18
18
 
19
19
  ```js
20
- const ejs = require('@kosatyi/ejs');
21
-
20
+ import {configure, helpers, render} from '@kosatyi/ejs'
22
21
  // path where templates is located
23
- ejs.configure({
22
+ configure({
24
23
  path: 'views'
25
24
  })
26
-
27
25
  // add custom template helper functions
28
- ejs.helpers({
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
- ejs.render('page/index',{
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 { Bundler } from '../dist/esm/bundler.js'
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
- withObject: false,
13
- export: 'ejsPrecompiled',
12
+ strict: true,
13
+ globals: '',
14
+ precompiled: 'ejsPrecompiled',
14
15
  path: 'views',
15
16
  extension: 'ejs',
16
17
  })
17
18
 
18
- if (typeof params.target !== 'string') {
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
- withObject: params.withObject,
40
+ strict: params.strict,
30
41
  path: params.path,
31
- export: params.export,
42
+ precompiled: params.precompiled,
32
43
  extension: params.extension,
44
+ globals: params.globals,
33
45
  }
34
46
 
35
- const bundler = Bundler(options, config)
47
+ const bundle = bundler(options, config)
36
48
 
37
- await bundler.build()
49
+ await bundle.build()
38
50
 
39
51
  if (params.watch && params.path) {
40
- await bundler.watch()
52
+ await bundle.watch()
41
53
  }