Skip to content

Commit

Permalink
🐛 recursive resolve of dynamic text
Browse files Browse the repository at this point in the history
  • Loading branch information
ebullient committed Nov 29, 2023
1 parent c5e8346 commit 6f3c0a8
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,21 @@ JsonNode mergeNodes(Tools5eIndexType type, String originKey, JsonNode copyFrom,
* @param copyTo JsonNode with attributes that can be used to resolve templates
*/
private JsonNode resolveDynamicText(String originKey, JsonNode value, JsonNode target) {
if (value == null || !(value.isArray() || value.isObject() || value.isTextual())) {
return value;
}
if (value.isArray()) {
for (int i = 0; i < value.size(); i++) {
((ArrayNode) value).set(i, resolveDynamicText(originKey, value.get(i), target));
}
return value;
}
if (value.isObject()) {
for (Entry<String, JsonNode> e : iterableFields(value)) {
e.setValue(resolveDynamicText(originKey, e.getValue(), target));
}
return value;
}
Matcher matcher = variable_subst.matcher(value.toString());
while (matcher.find()) {
String[] pieces = matcher.group("variable").split("__");
Expand Down

0 comments on commit 6f3c0a8

Please sign in to comment.