@peter.naydenov/morph 1.0.3 → 1.1.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/Changelog.md CHANGED
@@ -2,14 +2,25 @@
2
2
 
3
3
 
4
4
 
5
+ ### 1.1.1 ( 2025-01-20 )
6
+ - [x] Improve: Error messages when using method "set" with string;
7
+
8
+
9
+
10
+ ### 1.1.0 ( 2025-01-19 )
11
+ - [x] Ignore html comment sections in templates;
12
+
13
+
14
+
5
15
  ### 1.0.3 (2025-01-10)
6
- - [x] Fix: Render functions should receive dependencies;
16
+ - [x] Fix: Action should receive dependencies when data is a function;
7
17
 
8
18
 
9
19
 
10
20
  ### 1.0.2 (2025-01-09)
11
21
  - [x] Fix: Render nested components;
12
- - [ ] Bug: Render functions should receive dependencies;
22
+ - [x] Refactoring: Placeholder with actions when data is a function;
23
+ - [ ] Bug: Action should receive dependencies when data is a function;
13
24
 
14
25
 
15
26
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@peter.naydenov/morph",
3
3
  "description": "Template engine",
4
- "version": "1.0.3",
4
+ "version": "1.1.1",
5
5
  "license": "MIT",
6
6
  "author": "Peter Naydenov",
7
7
  "main": ".src/main.js",
package/src/main.js CHANGED
@@ -35,6 +35,11 @@ const storage = ( () => ({default: {}}) ) ();
35
35
  * either the storage or template does not exist.
36
36
  */
37
37
  function get ( location ) {
38
+ if ( !(location instanceof Array) ) {
39
+ return function () {
40
+ return 'Error: Argument "location" is a string. Should be an array. E.g. ["templateName", "storageName"].'
41
+ }
42
+ }
38
43
  const [prop, strName='default'] = location;
39
44
  if ( !storage[strName] ) {
40
45
  return function () {
@@ -16,8 +16,14 @@ function _readTemplate ( tpl ) {
16
16
  , placeholders = []
17
17
  ;
18
18
 
19
+ // Remove from template all html comments and multiple spaces
20
+ const Thetemplate = (typeof template === 'string') ? template
21
+ .replace(/<!--[\s\S]*?-->/g, '')
22
+ .replace ( /\s{2,}/g, ' ' )
23
+ : template
24
+
19
25
  let hasError = null;
20
- const chop = _chopTemplate (settings)( template );
26
+ const chop = _chopTemplate (settings)( Thetemplate );
21
27
 
22
28
  if ( typeof chop === 'string' ) hasError = chop
23
29
  else {