Exemple #1
0
func createTemplate(templateName string) *template.Template {
	template, err := amber.CompileFile("tmpl/posts_index.amber", amber.DefaultOptions)
	if err != nil {
		log.Fatal(err)
	}
	return template
}
Exemple #2
0
func renderBoardsIndex(w http.ResponseWriter) {
	t, err := amber.CompileFile("tmpl/boards_index.amber", amber.DefaultOptions)
	var boards []Board
	db.Order("created_at desc").Find(&boards)

	data := struct {
		Title  string
		Boards []Board
	}{
		Title:  "My page",
		Boards: boards,
	}
	if err != nil {
		log.Fatal(err)
	}
	t.Execute(w, data)
}