March 2019
Intermediate to advanced
336 pages
9h 9m
English
The following code shows how the Alter function renders the Home template by invoking the ExecuteTemplate method with the writer and customers arrays as parameters:
// Alter - execute templatefunc Alter(writer http.ResponseWriter, request *http.Request) { var customer Customer var customerId int var customerIdStr string customerIdStr = request.FormValue("id") fmt.Sscanf(customerIdStr, "%d", &customerId) customer.CustomerId = customerId customer.CustomerName = request.FormValue("customername") customer.SSN = request.FormValue("ssn") UpdateCustomer(customer) var customers []Customer customers = GetCustomers() template_html.ExecuteTemplate(writer,"Home",customers)}
Read now
Unlock full access