First, when posting code, templates, or error messages here, please enclose the text between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code (or template, etc), then another line of ```. This forces the forum software to keep your code properly formatted.
(I’m taking the liberty of editing your original post for this. Please remember to do this in the future.)