Ruby template indentation issue - puppet

I’m unable to fix indentation for ruby template, I’ve spent hours on this and still couldn’t get it to work as expected.

Here is the template:

    <%= @log_path -%> {
      <%= @rotate_every %>
      rotate <%= @rotate_count %>
      compress
      <% if @delaycompress == true %>delaycompress
      <% end -%>missingok
      notifempty
      create <%= @create_mode -%> <%= @create_owner -%> <%= @create_group %>
      <% if @postrotate == true -%>postrotate
        <% @postrotate_cmd.each do |value| -%><%= value %>
      <% end -%>endscript<% end %>
    }

When @postrotate is false the output looks like this. The } is after a empty line.

    /var/log/auth.log {
      weekly
      rotate 4
      compress
      delaycompress
      missingok
      notifempty
      create 0644 root adm
      
      }

When @postrotate is true the output looks like this. The second invoke commnad should be a bit to the right.

    /var/log/auth.log {
      weekly
      rotate 4
      compress
      delaycompress
      missingok
      notifempty
      create 0644 root adm
      postrotate
        invoke-rc.d rsyslog reload > /dev/null
      invoke-rc.d rsyslog reload > /dev/null
      endscript
      }

Expected output when @postrotate is false:

    /var/log/auth.log {
      weekly
      rotate 4
      compress
      delaycompress
      missingok
      notifempty
      create 0644 root adm
    }

Expected output when @postrotate is true:

    /var/log/auth.log {
      weekly
      rotate 4
      compress
      delaycompress
      missingok
      notifempty
      create 0644 root adm
      postrotate
        invoke-rc.d rsyslog reload > /dev/null
        invoke-rc.d rsyslog reload > /dev/null
      endscript
    }