template-ize gallery

maybe this is a little less ugly. :)