Enhanced to support JQuery references in 'template' parameter