Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Allow to parameterize scripts via bindings #46

Open
kwin opened this issue May 25, 2020 · 1 comment
Open

Allow to parameterize scripts via bindings #46

kwin opened this issue May 25, 2020 · 1 comment

Comments

@kwin
Copy link
Member

kwin commented May 25, 2020

It would be nice to pass properties from the hook to all contained scripts (e.g. to influence the root node from which to start). Otherwise this information has to be repeated in all contained scripts. For Groovy/Scripting and Sling Pipes one can use bindings for that. I would suggest that nested properties with a specific name are created as bindings automatically

@nc-andreashaller
Copy link
Collaborator

nc-andreashaller commented May 29, 2020

EDIT: if you are using GroovyConsole script you can set a property data on the parent node of the scripts. The content is interpreted as Json and added to the script as a binding:

package definition

vtl:definition
  - upgrader
      - your_script_folder
          - properties:
              - handler=groovyconsole
              - data={"myBinding":"custom-value"}
          - script0.groovy

script0.groovy

println data.myBinding

Still we should find a way for the other handlers and document the above properly.

very good point, in GroovyConsole scripts there is already a workaround for that:
With slingRequest['scriptPath'] you can access the path of the current script and with that information you can read properties of that node or the parent node via normal means

But you are totally right, a more elegant solution for that would be awesome.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants