@bonniernews/local-esi
Advanced tools
Comparing version 2.0.2 to 2.1.0
@@ -11,2 +11,8 @@ Changelog | ||
## [2.1.0] - 2021-12-20 | ||
### Added | ||
- Support `$string_split` | ||
- Support named `item` variable in foreach | ||
## [2.0.2] - 2021-12-20 | ||
@@ -13,0 +19,0 @@ |
@@ -170,2 +170,3 @@ /* eslint-disable no-use-before-define */ | ||
} | ||
context.itemVariableName = data.item || "item"; | ||
@@ -184,4 +185,5 @@ context.foreachChunks = []; | ||
if (Array.isArray(value)) value = `[${value.map((v) => typeof v === "string" ? `'${v}'` : v).join(",")}]`; | ||
buffered = buffered.concat([ { | ||
name: "esi:assign", data: { name: "item", value: value.toString() }, | ||
name: "esi:assign", data: { name: context.itemVariableName, value: value.toString() }, | ||
}, { name: "esi:assign" } ], foreachChunks); | ||
@@ -188,0 +190,0 @@ } |
@@ -72,2 +72,10 @@ /* eslint-disable camelcase */ | ||
} | ||
string_split([ arg1, arg2 ]) { | ||
const stringToSplit = this.execute(arg1.type, arg1); | ||
const splitBy = this.execute(arg2.type, arg2); | ||
if (typeof stringToSplit !== "string" || typeof splitBy !== "string") { | ||
throw new Error("string_split requires two arguments of type string"); | ||
} | ||
return stringToSplit.split(splitBy); | ||
} | ||
substr([ arg1, arg2, arg3 ]) { | ||
@@ -74,0 +82,0 @@ const string = this.execute(arg1.type, arg1); |
{ | ||
"name": "@bonniernews/local-esi", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"description": "Local Edge Side Includes parser", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53328
1603