The `require` callback is asynchronous, so there is no guarantee that `$template` would be changed before the template is rendered. I'm still thinking that you'd be better off with 2 separate dedicated functions here.