Why does this condition keep giving me errors?

I’ve just lost a few hours searching for a solution to the same problem. Even an example on the Home Assistant documentation has it wrong (https://www.home-assistant.io/docs/automation/condition/):

      - condition: template
        value_template: '{{ state_attr('sun.sun', 'elevation') < 4 }}'

I would like to modify the documentation, but I’m not familiar at al with github :frowning:
PS: http://www.yamllint.com/ is also a good place to check your yaml

I put it in https://github.com/home-assistant/home-assistant.io/pull/11688