Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy path name as value? #348

Open
TobiasNx opened this issue May 2, 2024 · 2 comments
Open

Copy path name as value? #348

TobiasNx opened this issue May 2, 2024 · 2 comments

Comments

@TobiasNx
Copy link
Collaborator

TobiasNx commented May 2, 2024

Sometimes it can be necessary to copy the path name as value, at the moment we cannot do this.

@blackwinter
Copy link
Member

Can you please add an example of your use case?

@TobiasNx
Copy link
Collaborator Author

TobiasNx commented May 2, 2024

It could provide a solution for #349 :

we could introduce a function path_as_value

e.g.

input:

a:
	- dog
	- cat
	- bird
set_array("animals[]")
do list("a","var":"$i")
	copy_field("$i","animals[].$append.name")
	path_as_value("$i","animals[].$last.pos")
end

replace_all("animals[].*.pos","^.*(\\d*)$","$1")
retain("animals[]")
animals:
	- name: dog
	  pos: 1
	- name: cat
	  pos: 2
	- name: bird
	  pos: 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants