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

Pass values from parent to imported jslt #275

Open
anuradharajan opened this issue Nov 1, 2022 · 3 comments
Open

Pass values from parent to imported jslt #275

anuradharajan opened this issue Nov 1, 2022 · 3 comments
Labels
support Users asking how to solve a specific issue

Comments

@anuradharajan
Copy link

Hi - Is there a way to pass values from parent jslt to the imported jslt?

@larsga larsga added the support Users asking how to solve a specific issue label Nov 1, 2022
@larsga
Copy link
Collaborator

larsga commented Nov 1, 2022

Only as parameters to the functions declared in the imported JSLT, I'm afraid.

Could you explain the use case?

@anuradharajan
Copy link
Author

Parent jslt
import "common.jslt" as common
let val1 = "someVal"
common:setVal($val1)

I want to access val1 in my common.jslt

I tried this in common.jslt
let val1 = ""
def setVal(propValue)
val1 = propValue

{
"val1" : ${val1}
}

Getting the following exception
com.schibsted.spt.data.jslt.JsltException: Parse error: Encountered " "let" "let ""
on this line
common:setVal($val1)

@larsga
Copy link
Collaborator

larsga commented Nov 1, 2022

Thank you, but this is not a use case. This is a full example of trying to do this, but it gives no indication of why you might want to do something like this. The reason I asked is that it's useful to see why you wanted this in the first place. Maybe there is an easier way to achieve the same thing in the language, or maybe there is a good reason why we need to support something like this. Either the way you wanted it, or some other way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Users asking how to solve a specific issue
Projects
None yet
Development

No branches or pull requests

2 participants