The template data object

The template data object that will be passed to the template renderer will be a templatedata.ShoppingCart struct (defined in the shared/templatedata/shoppingcart.go source file):

type ShoppingCart struct {
PageTitle string
Products []*models.Product
}

The PageTitle field will be used to display the web page title and the Products field, a slice of Product objects, will be used to display the products that are currently in the shopping cart.

Now that we have the templates in place, let's take a look at modeling the shopping cart.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.178.9