Refactors gallery template to use one tpl file