You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I could not find any mechanism to extend a list, I am trying to build a list of strings and work with the result in several spots to loop on it. The main idea is building a comma separated list as string and then split it by comma. However, the split method returns an array of String and I am not able to iterate on it. (The only method which works with an array is the join method, which can actually only work on a result of the split method and I don't see any meaningful use case for it.)
I would propose the following options to enhance the scripting capabilities :
Provide custom additional methods split and join, which work with List<String>, instead of using the ones from StringUtils.
Alternatively, new additional method(s) might be introduced to extend an existing list, such as extendList(List<String>, String) and appendList(List<String>, List<String>).
Sample block when the method extendList introduced :
- DEF MY_SITE_LIST=[]
- FOR siteNode IN CHILDREN OF /content:
- DEF siteName=${siteNode.name}
- DEF MY_SITE_LIST=${extendList(MY_SITE_LIST, siteName)}
- FOR siteName IN ${MY_SITE_LIST}:
- DEF siteGroupName="sample-group-${siteName}"
- ${siteGroupName}:
- path: "/home/groups/myproject/${siteGroupName}"
P.S.: Once the improvements prepared, the last block needs to be tested. As far as I remember, the changes on MY_LIST is only in effect within the outermost FOR loop. Outside of the loop, it remains intact. This causes code duplicates, as overriding a global variable within a loop is not possible.
The text was updated successfully, but these errors were encountered:
As I could not find any mechanism to extend a list, I am trying to build a list of strings and work with the result in several spots to loop on it. The main idea is building a comma separated list as string and then split it by comma. However, the
split
method returns an array of String and I am not able to iterate on it. (The only method which works with an array is thejoin
method, which can actually only work on a result of the split method and I don't see any meaningful use case for it.)I would propose the following options to enhance the scripting capabilities :
split
andjoin
, which work withList<String>
, instead of using the ones from StringUtils.extendList(List<String>, String)
andappendList(List<String>, List<String>)
.Sample block when the method
extendList
introduced :P.S.: Once the improvements prepared, the last block needs to be tested. As far as I remember, the changes on MY_LIST is only in effect within the outermost FOR loop. Outside of the loop, it remains intact. This causes code duplicates, as overriding a global variable within a loop is not possible.
The text was updated successfully, but these errors were encountered: