klum-dsl / klum-ast

Turn your models into super models
https://github.com/klum-dsl/klum-ast/wiki
MIT License
3 stars 0 forks source link

Rethink deep templates #325

Open pauxus opened 5 months ago

pauxus commented 5 months ago

given the following template:

def template = Outer.Create.Template {
  inner {
    innerValue "1"
  }
}

And applied to the following config:

TemplateManager.withTemplate(template) {
  Outer.Create.With {
    inner {
      anotherValue "1"
    }
  }
}

would result in the creation of a completely new inner object, so the "innerValue" would be dropped, which is counterintuitive.

I see a couple of possibilities to implement this:

1) A complex template could be split into multiple templates which are all applied at once. With layer3 code, this is easy to implement, however, this has two issues:

Both approaches are breaking changes. (2) seems better, but depends on more work on copyStrategies and is more complex in implementation but probably the way to got.