Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm no fan of YAML but for an example of templating YAML that is tolerable, take a look at esphome[1] (and I suppose also home assistant).

In your main yaml file you have something like this:

  packages:
    left_garage_door: !include
      file: garage-door.yaml
      vars:
        door_name: Left
        door_location: left
        open_switch_gpio: 25
        close_switch_gpio: 26
Then in garage-door.yaml you can reference the vars directly with ${door_name} syntax.

It's the best version of templating YAML that I have experienced.

1. https://esphome.io/guides/configuration-types#packages-as-te...



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: