Fix edge case for dynamic templates