You can also just use 1 template and use variables
like this
%if num_of_normal_port=10%
untagged 8,9,10
%endif%
like this
%if num_of_normal_port=28%
untagged 8,9,10
%endif%
this work on a 8 port aruba switch (8 rj45 and 2 sfp = 10) and 24 port switch.
This works on both vlans and interface configuration