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
-
Wow, sorry for the title 🙈
Given I have a template like this:
Now I have two files that
amends
it:So basically, file b is identical to file a, except of a single job.
I thought I can extract a
BaseJobber
that amendsJobber
and have somekind ofcustomJobs: Listing<Job>
.My
BaseJobber
could look like that:And the childs can amends
BaseJobber
and only overridecustomJobs
with their custom jobs.But this doesn't work. I can't introduce new properties when I
amend
a module.In my current solution I use
import Jobber
in myBaseJobber
and define defaults.Plus a function like
With that the child can call
amends
theJobber
andimport
theBaseJobber
and 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