The template editor does not run services, it just renders Jinja templates. The code you’ve posted is YAML config, not a Jinja template — with the exception of the two {{ }} bits. Because it does not run the service, hourly is not populated and the error is generated.
I realise it starts with template:, but it isn’t one.
What you have experienced is expected behaviour.
You need to include that YAML config in configuration.yaml.