Accessing amended values without declaring locals #940
-
| 
         I'm trying to create a template with certain constant values that'd I'd like to be accessible to users of the template. Is there a way to do this without creating a local in the amended module? Here's a very minimal example of what I'm talking about // template.pkl
module template
const value = "some constant value"
config: Listing<String>// config.pkl
amends "template.pkl"
config = new Listing {
    "foo"
    "bar"
    "baz-\(value)"
}Trying to evaluate this returns an error:  I can sort of overcome this by defining a local property: // config2.pkl
amends "template.pkl"
local val = value
config = new Listing {
    "foo"
    "bar"
    "baz-\(val)"
}However, in more complex scenarios this becomes very inconvenient. When you have several levels of amended templates for instance. Needing to create a local property in every place in the template hierarchy where you need to use the value quickly becomes a problem. Is there a better way to accomplish this?  | 
  
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
| 
         You can access this using  config {
    "foo"
    "bar"
    "baz-\(module.value)"
} | 
  
Beta Was this translation helpful? Give feedback.
You can access this using
module: