spooder 6.1.94 → 6.1.95
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/package.json +1 -1
- package/src/api.ts +7 -4
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -978,13 +978,16 @@ export async function parse_template(template: string, replacements: Replacement
|
|
|
978
978
|
const if_regex = /<t-if\s+test="([^"]+)"\s*>(.*?)<\/t-if>/gs;
|
|
979
979
|
result = await replace_async(result, if_regex, async (match, condition_key, if_content) => {
|
|
980
980
|
const condition_value = is_replacer_fn ? await replacements(condition_key) : replacements[condition_key];
|
|
981
|
-
|
|
982
|
-
|
|
981
|
+
const key_exists = is_replacer_fn || (condition_key in replacements);
|
|
982
|
+
|
|
983
|
+
// preserve block for later pass if key doesn't exist and drop_missing is false
|
|
984
|
+
if (!key_exists && !drop_missing)
|
|
983
985
|
return match;
|
|
984
|
-
|
|
986
|
+
|
|
987
|
+
// render content if condition is truthy, otherwise remove block
|
|
985
988
|
if (condition_value)
|
|
986
989
|
return await parse_template(if_content, replacements, drop_missing);
|
|
987
|
-
|
|
990
|
+
|
|
988
991
|
return '';
|
|
989
992
|
});
|
|
990
993
|
|