@kosatyi/ejs 0.0.43 → 0.0.45

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.
@@ -0,0 +1,84 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var isUndefined = function isUndefined(v) {
6
+ return typeof v === 'undefined';
7
+ };
8
+
9
+ Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]';
10
+ var symbolEntities = {
11
+ "'": "'",
12
+ '\\': '\\',
13
+ '\r': 'r',
14
+ '\n': 'n',
15
+ '\t': 't',
16
+ "\u2028": 'u2028',
17
+ "\u2029": 'u2029'
18
+ };
19
+ var htmlEntities = {
20
+ '&': '&',
21
+ '<': '&lt;',
22
+ '>': '&gt;',
23
+ '"': '&quot;',
24
+ "'": '&#x27;'
25
+ };
26
+ var regexKeys = function regexKeys(obj) {
27
+ return new RegExp(['[', Object.keys(obj).join(''), ']'].join(''), 'g');
28
+ };
29
+ var htmlEntitiesMatch = regexKeys(htmlEntities);
30
+ regexKeys(symbolEntities);
31
+ var entities = function entities() {
32
+ var string = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
33
+ return ('' + string).replace(htmlEntitiesMatch, function (match) {
34
+ return htmlEntities[match];
35
+ });
36
+ };
37
+ var each = function each(object, callback) {
38
+ var prop;
39
+ for (prop in object) {
40
+ if (hasProp(object, prop)) {
41
+ callback(object[prop], prop, object);
42
+ }
43
+ }
44
+ };
45
+ var map = function map(object, callback, context) {
46
+ var result = [];
47
+ each(object, function (value, key, object) {
48
+ var item = callback(value, key, object);
49
+ if (isUndefined(item) === false) {
50
+ result.push(item);
51
+ }
52
+ });
53
+ return result;
54
+ };
55
+ var hasProp = function hasProp(object, prop) {
56
+ return object && object.hasOwnProperty(prop);
57
+ };
58
+
59
+ var selfClosed = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
60
+ var space = ' ';
61
+ var quote = '"';
62
+ var equal = '=';
63
+ var slash = '/';
64
+ var lt = '<';
65
+ var gt = '>';
66
+ var element = function element(tag, attrs, content) {
67
+ var result = [];
68
+ var hasClosedTag = selfClosed.indexOf(tag) === -1;
69
+ var attributes = map(attrs, function (value, key) {
70
+ if (value !== null && value !== undefined) {
71
+ return [entities(key), [quote, entities(value), quote].join('')].join(equal);
72
+ }
73
+ }).join(space);
74
+ result.push([lt, tag, space, attributes, gt].join(''));
75
+ if (content) {
76
+ result.push(content instanceof Array ? content.join('') : content);
77
+ }
78
+ if (hasClosedTag) {
79
+ result.push([lt, slash, tag, gt].join(''));
80
+ }
81
+ return result.join('');
82
+ };
83
+
84
+ exports.element = element;
package/package.json CHANGED
@@ -2,15 +2,35 @@
2
2
  "name": "@kosatyi/ejs",
3
3
  "description": "EJS Templates",
4
4
  "homepage": "https://github.com/kosatyi/ejs",
5
- "version": "0.0.43",
6
- "main": "dist/ejs.cjs",
7
- "module": "dist/ejs.mjs",
8
- "browser": "dist/ejs.js",
9
- "minified": "dist/ejs.min.js",
5
+ "type": "module",
6
+ "version": "0.0.45",
7
+ "main": "dist/cjs/ejs.js",
8
+ "module": "dist/mjs/ejs.js",
9
+ "browser": "dist/umd/ejs.js",
10
+ "minified": "dist/umd/ejs.min.js",
10
11
  "author": "Stepan Kosatyi (https://kosatyi.com)",
11
12
  "dependencies": {
12
13
  "chokidar": "^3.5.3"
13
14
  },
15
+ "exports": {
16
+ ".": {
17
+ "types": "./ejs.d.ts",
18
+ "import": "./dist/mjs/ejs.js",
19
+ "require": "./dist/cjs/ejs.js"
20
+ },
21
+ "./element": {
22
+ "types": "./element.d.ts",
23
+ "import": "./dist/mjs/element.js",
24
+ "require": "./dist/cjs/element.js"
25
+ }
26
+ },
27
+ "typesVersions": {
28
+ "*": {
29
+ "element": [
30
+ "element.d.ts"
31
+ ]
32
+ }
33
+ },
14
34
  "files": [
15
35
  "dist",
16
36
  "ejs.d.ts",
File without changes
File without changes
File without changes
File without changes
File without changes