Click here to Skip to main content
15,885,014 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
func Home(w http.ResponseWriter, r *http.Request) {
	if r.URL.Path != "/" {
		fmt.Fprintln(w, "404 page not found")
		return
	}
	for i := 0; i < 34; i++ {
		user := List{ProductsList: string(products.AccessDataFromFile(i))}
        HomeTmpl.Execute(w, user)
	}
}

>>>>>>>>  This is the HTML file

<body>
    <h1>{{ (index . 0).ProductsList }}</h1>
</body>


What I have tried:

In this code, I am getting the data from the CSV file and I want to parse it in an HTML file. I set the index in an HTML file to print only the first product and I executed the template but it printed all the products.

Although I set the index . 0 but it still didn't work.
Posted
Updated 20-Nov-21 5:36am
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900