Replies: 1 comment 1 reply
-
|
There's multiple ways to skin the cat! One pattern is to define another module that sets its output to the underlying module's output. It can then expose // Jobber.pkl
module Jobber
jobs: Listing<Job>
class Job { name: String }// fancyJobber.pkl
import "Jobber.pkl"
customJobs: Listing<Jobber.Job>
fixed jobber: Jobber = new {
jobs {
new { name = "job 1" }
new { name = "job 2" }
...customJobs
new { name = "job 3" }
new { name = "job 4" }
}
}
output = jobber.output// myFancyJobber.pkl
amends "fancyJobber.pkl"
customJobs {
new { name = "my custom job" }
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Wow, sorry for the title 🙈
Given I have a template like this:
Now I have two files that
amendsit:So basically, file b is identical to file a, except of a single job.
I thought I can extract a
BaseJobberthat amendsJobberand have somekind ofcustomJobs: Listing<Job>.My
BaseJobbercould look like that:And the childs can amends
BaseJobberand only overridecustomJobswith their custom jobs.But this doesn't work. I can't introduce new properties when I
amenda module.In my current solution I use
import Jobberin myBaseJobberand define defaults.Plus a function like
With that the child can call
amendstheJobberandimporttheBaseJobberand basically delegating everything to it.This works, but doesn't look correct 🫠
What is the pkl way to go to handle this case? 🤔
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions