Stop duplicating common html page data

Issue #412 resolved
Trek Hopton created an issue

Whenever we write code for a new page for VidGrind, we copy all the fields from the pagedata struct for all the commonly used fields. We should structure it so that we don’t have to copy over the fields but instead we only add the fields for data specific to the new page.

This is done in preparation for adding the sitemenu to all pages, as I would have had to add a User slice to each page handler’s data.

Comments (3)

  1. Alan Noble

    We should use struct embedding which, AFAIK, is the preferred approach in Go.

    So we define our commonPagedata (i.e, what is now pagedata), then embed it on other pages.

    type commonPageData struct {  // was page data
      // common fields
    }
    
    type adminPageData struct {
      // admin-specific fields
      commonPageData
    } 
    

  2. Log in to comment