Does this syntax work?
$("."+defaultFormInputContainer, $template).andSelf().attr...

Could shorten things a bit, I think it does the same thing.