mikel 0.26.1 → 0.27.0

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.
Files changed (3) hide show
  1. package/README.md +12 -0
  2. package/index.js +6 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -36,6 +36,18 @@ const result = m(`Hello {{name || "World"}}!`, {});
36
36
  // Output: 'Hello World!'
37
37
  ```
38
38
 
39
+ ### Comments
40
+
41
+ > This feature was added in `v0.27.0`.
42
+
43
+ Any content between `{{!--` and `--}}` will be completely ignored during template rendering. Comments can span multiple lines and are not included in the output or parsed AST.
44
+
45
+ ```
46
+ {{!-- This is a comment --}}
47
+ ```
48
+
49
+ > **Note**: Nested comments are not supported. The first closing `--}}` encountered will terminate the comment block.
50
+
39
51
  ### Sections
40
52
 
41
53
  Sections allow for conditional rendering of blocks of content based on the presence or absence of a value in the data object. Use the pound symbol `#` to start a section and the caret `^` to denote an inverted section. End the section with a forward slash `/`.
package/index.js CHANGED
@@ -16,8 +16,12 @@ const get = (data, path = ".") => {
16
16
  return path.replace(/^this\./, "").split(".").reduce((x, k) => x?.[k], data) ?? "";
17
17
  };
18
18
 
19
- // @description tokenize and untokenize methods
20
- const tokenize = (str = "") => str.split(/\{\{|\}\}/);
19
+ // @description tokenize the provided string
20
+ const tokenize = (str = "") => {
21
+ return str.replace(/\{\{!--[\s\S]*?--}}/g, "").split(/\{\{|\}\}/);
22
+ }
23
+
24
+ // @description untokenize the provided tokens array and get a string
21
25
  const untokenize = (ts = [], s = "{{", e = "}}") => {
22
26
  return ts.length > 0 ? ts.reduce((p, t, i) => p + (i % 2 === 0 ? e : s) + t) : "";
23
27
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mikel",
3
3
  "description": "Micro templating library with zero dependencies",
4
- "version": "0.26.1",
4
+ "version": "0.27.0",
5
5
  "type": "module",
6
6
  "author": {
7
7
  "name": "Josemi Juanes",