$template as function