Use mixin and then override parts of it, for instance default value

Many times I find myself copying the content of mixins into other xml files instead of just using the mixin, because I want a slight variation on the mixin.

For example let’s say I have the following mixin:

<mixin>
  <display-name>Mixin displayName</display-name>
  <items>
    <input type="TextLine" name="someTextLine">
      <label>Some text line</label>
      <occurrences minimum="0" maximum="1"/>
    </input>
  </items>
</mixin>

And in my use case I want it to be a required field.
Currently I’ll have to duplicate the whole mixin and make one optional and one required variant.
For more complex mixins, there might be many many variants.

It would be nice if we could override/decorate the mixin, something like this:

<inline mixin="mixinName">
  <input name="someTextLine">
    <occurrences minimum="1"/>
  </input>
</inline>
1 Like

I guess programable definitions rather than xml files would solve this too…

Hi.

This could be done in the form of templates in build - generate xml’s based on code. It’s doable in gradle today. I would create a task generateMixin in gradle that could use xml-building feature of gradle (http://groovy-lang.org/processing-xml.html).