Folded vs literal style yaml template in developer service box vs automation service calls?

Hi, confused about this.

I use this template in the developer call service dev box, and it correctly adjusts the corresponding input_text to the next 30 min period, if the current value is in the past. But when run as an action in an automation, the result is a blank value:

service: input_text.set_value
data:
  value: |
    {% if now() > today_at(states('input_text.octopus_incoming_target_from')) %}
    {% if now().minute > 30 %}
    {{ (now()+timedelta(hours = 1)).strftime("%H") }}:00
    {% else %}
    {{ now().strftime("%H") }}:30
    {%endif %}
    {%endif %}
target:
  entity_id: input_text.octopus_incoming_target_from

However, if I use “folded style” yaml in the automation:

service: input_text.set_value
data:
  value: >
    {% if now() > today_at(states('input_text.octopus_incoming_target_from')) %}

    {% if now().minute > 30 %}

    {{ (now()+timedelta(hours = 1)).strftime("%H") }}:00

    {% else %}

    {{ now().strftime("%H") }}:30

    {%endif %}

    {%endif %}
target:
  entity_id: input_text.octopus_incoming_target_from

its fine in the automation context, but in the developer ‘call-state’ service dev tool, same code ends up leaving a blank value!

So it appears the same yaml is not being interpreted quite the same way from the UI, which wasn’t at all obvious to me. And its not helpful that there seemed to be no error message, so it silently ignored my template until I happened to hit on the fact it was the | vs > causing the problem. What am I missing?

Thanks

If a template supposed to return a single-line-string - why do you intentionally paste line-breaks?
Copy whole template (-s) into Dev tools - Template and see empty lines.

Google “yaml multiline” about a difference between “|” and “>”.

Also, compare

{% ... -%}
{%- ... %}

and

{% ... %}
{% ... %}

Sorry, my fault, its not the | or > its the logic. I realised of course I’m alternately clearing / setting the input without an ‘else’ to the first ‘if’. Line breaks don’t help either I agree they shouldn’t be there and was further confusing the issue.