Platform Template format

I use the Template platform and one of the code is the following:

  - platform: template
    sensors:
      sunset_time:
        value_template: '{{ as_timestamp(states.sun.sun.attributes.next_setting)  | timestamp_custom("%H:%M") }}'
      sunrise_time:
        value_template: '{{ as_timestamp(states.sun.sun.attributes.next_rising)  | timestamp_custom("%H:%M") }}'

I am thinking it should be like this:

  - platform: template
    sensors:
      - sunset_time:
          value_template: '{{ as_timestamp(states.sun.sun.attributes.next_setting)  | timestamp_custom("%H:%M") }}'
      - sunrise_time:
          value_template: '{{ as_timestamp(states.sun.sun.attributes.next_rising)  | timestamp_custom("%H:%M") }}'

But the second form does not work for me here, in Template sensor, while similar syntax works fine in other places, like Sensors. Is is as described in the examples, but I miss why this difference.

That’s just the case with template sensors: - it doesn’t expect a list. The hyphen (-) denotes a list in YAML.