It's not about how to declare a function. Template should be as simple as possible. Quick search  says that this code is shared with other apps e.g. files:
Rewriting this part would touch other apps and should be done for master. 
https://github.com/owncloud/core/blob/master/apps/files/templates/part.list.php#L12
https://github.com/owncloud/core/blob/master/apps/files/templates/part.breadcrumb.php#L10