Custom Light Detection Sensor

Hi! I just am getting involved with templates and customary sensors, just by watching videos and browsing other topics here. I set up and tested the code and it operates properly on the Developer Tools Template editor, however when I transfer it to sensors.yaml it errors out with “can not read an implicit mapping pair” among others. Any help would be appreciated and many thanks!

My code is below:

# Dish Washer Light Sensor #
- platform: template
  sensors:
  dish washer status:
  friendly_name: Dish Washer Status
  value_template: >-
  {{ states('binary_sensor.dishwasher_flex_sensor_light') }}
  {% if states('binary_sensor.dishwasher_flex_sensor_light_detection') == 'on' %}

On
{% else %}
Off
{% endif %}
	      icon_template: mdi:lightning-bolt-circle