spooder 4.2.6 → 4.2.7
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 +2 -2
- package/package.json +1 -1
- package/src/api.ts +2 -7
package/README.md
CHANGED
|
@@ -962,12 +962,12 @@ parse_template(template, replacements, true);
|
|
|
962
962
|
`parse_template` supports looping arrays with the following syntax.
|
|
963
963
|
|
|
964
964
|
```html
|
|
965
|
-
{$for:foo}My colour is {
|
|
965
|
+
{$for:foo}My colour is %s{/for}
|
|
966
966
|
```
|
|
967
967
|
```ts
|
|
968
968
|
const template = `
|
|
969
969
|
<ul>
|
|
970
|
-
{$for:foo}<li
|
|
970
|
+
{$for:foo}<li>%s</li>{/for}
|
|
971
971
|
</ul>
|
|
972
972
|
`;
|
|
973
973
|
|
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -132,14 +132,9 @@ export function parse_template(template: string, replacements: Record<string, st
|
|
|
132
132
|
} else {
|
|
133
133
|
const loop_content = template.substring(loop_content_start_index, loop_close_index);
|
|
134
134
|
if (loop_entries !== undefined) {
|
|
135
|
-
const inner_replacements = {
|
|
136
|
-
...replacements,
|
|
137
|
-
entry: ''
|
|
138
|
-
};
|
|
139
|
-
|
|
140
135
|
for (const loop_entry of loop_entries) {
|
|
141
|
-
|
|
142
|
-
result += parse_template(
|
|
136
|
+
const inner_content = loop_content.replaceAll('%s', loop_entry);
|
|
137
|
+
result += parse_template(inner_content, replacements, drop_missing);
|
|
143
138
|
}
|
|
144
139
|
} else {
|
|
145
140
|
if (!drop_missing)
|