func showSubjects(w http.ResponseWriter, r *http.Request, message string) {
	redirected, _ := ensureLoggedIn(w, r)
	if redirected {
		return
	}

	// Prepare the template data with all subjects.
	templateData := struct {
		generalTemplateData
		Subjects []model.Subject
		Unknown  []model.UnknownSubject
	}{Subjects: model.ReadAllSubjects(),
		Unknown: model.ReadAllUnknownSubjects()}
	// Add the message if there is one.
	if message != "" {
		templateData.Messages = []templateMessage{templateMessage{Text: message, Positive: true}}
	}

	// Render.
	template, err := template.ParseFiles("templates/base.html", "templates/subject/index.html")
	if err != nil {
		log.Printf("error: %v\n", err)
	}

	err = template.Execute(w, &templateData)
	if err != nil {
		log.Printf("error: %v\n", err)
	}
}
// showSubjects is a helper function to show a list of all subjects.
showSubjects is a helper function to show a list of all subjects.
// showSubjects is a helper function to show a list of all subjects .
func showSubjects(w http.ResponseWriter, r *http.Request, message string) {
	redirected, _ := ensureLoggedIn(w, r)
	if redirected {
		return
	}
	templateData := struct {
		generalTemplateData
		Subjects []model.Subject
		Unknown  []model.UnknownSubject
	}{Subjects: model.ReadAllSubjects(),
		Unknown: model.ReadAllUnknownSubjects()}
	if message != "" {
		templateData.Messages = []templateMessage{templateMessage{Text: message, Positive: true}}
	}
	template, err := template.ParseFiles("templates/base.html", "templates/subject/index.html")
	if err != nil {
		log.Printf("error: %v\n", err)
	}
	err = template.Execute(w, &templateData)
	if err != nil {
		log.Printf("error: %v\n", err)
	}
}
func showSubjects ( w http . ResponseWriter , r * http . Request , message string ) { redirected , _ := ensureLoggedIn ( w , r ) if redirected { return } templateData := struct { generalTemplateData Subjects [ ] model . Subject Unknown [ ] model . UnknownSubject } { Subjects : model . ReadAllSubjects ( ) , Unknown : model . ReadAllUnknownSubjects ( ) } if message != " " { templateData . Messages = [ ] templateMessage { templateMessage { Text : message , Positive : true } } } template , err := template . ParseFiles ( " " , " " ) if err != nil { log . Printf ( " \n " , err ) } err = template . Execute ( w , & templateData ) if err != nil { log . Printf ( " \n " , err ) } }
showSubjects is a helper function to show a list of all subjects.
showSubjects is a helper function to show a list of all subjects .
// Prepare the template data with all subjects. // Add the message if there is one. // Render.