template: fix checking of ellipsis-driving variables
  closes PR 14497
template: pre-allocate local env vectors for nested ellipses