-
Hi I'm brand new to pkl, but saw the talk at devoxx antwerp and was immediately in love. I'm trying to use the tool to autogenerate a lot of configuration files that we are currently writing manually with a lot of copy/pasting. One need I have come across is to amend an object in a for generator. If I try the following: hidden template {
name
body = """
This refers to the name [\(name)] which must be set by amending the template later on
"""
}
root {
for (n in List("a", "b")) {
x = (template) {
name = n
}
}
} I get the following error:
Is there a way for this to work? I tried to keep the above example as simple as possible, my real scenario is a bit more complex. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Can you show an example of what you'd like the output to look like here, given that input? I'm almost certain there's a solution for what you're trying to do, but I want to be sure to answer the question you're actually asking! |
Beta Was this translation helpful? Give feedback.
Gotcha, that makes a lot of sense. What you're doing is an application of the Class-as-a-function pattern!
I took a few minutes to digest your example and revise it a bit in a way that solves your immediate problem and here's what I came up with: