There is some code duplication due to intranet and opac templates not able to share code. Perhaps there should be a place in the source tree, such as koha-tmpl/shared-tmpl/ which is copied to both opac and intranet at install.
(For an example, see commit 8aa0e685)