Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inherit another template or optional variables? #68

Open
jeremywillans opened this issue May 19, 2023 · 3 comments
Open

Inherit another template or optional variables? #68

jeremywillans opened this issue May 19, 2023 · 3 comments

Comments

@jeremywillans
Copy link

Is your feature request related to a problem? Please describe.
I have several fairly duplicated templates which have something minor as a difference, for example an extra service-data parameter or one with an extra option.

Describe the solution you'd like
Is there a way to either inherit config from another template, or exclude parts of the template based on if you have specified the particular variable?

Describe alternatives you've considered
Multiple templates

@ildar170975
Copy link

Similar functionality may be achieved by "cascading" templates & using yaml anchors:

template_1:
  default: &ref_default
    - var_1: ...
    - var_2: ...
    - ...
  card:
    ...
...
template_2:
  default: *ref_default
  card:
    ...
    - &ref_calling_template_1
      type:custom:decluttering-card
      template: template_1
      variables:
        - var_1: '[[var_1]]'
        - var_2: '[[var_2]]'
    ...
...
template_3:
  default:
    ... new default values
  card:
    ... another functionality
    - *ref_calling_template_1
    ... another functionality

@jack3308
Copy link

Just to confirm, this approach would only work when using the yaml development method and not the UI, correct?

@ildar170975
Copy link

yaml-anchors are supported in yaml mode only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants