Created
January 19, 2016 04:16
-
-
Save IndianGuru/65908fe30dc43f69326d to your computer and use it in GitHub Desktop.
Handler using the same template in different template files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func process(w http.ResponseWriter, r *http.Request) { | |
rand.Seed(time.Now().Unix()) | |
var t *template.Template | |
if rand.Intn(10) > 5 { | |
t, _ = template.ParseFiles("layout.html", "red_hello.html") | |
} else { | |
t, _ = template.ParseFiles("layout.html", "blue_hello.html") | |
} | |
t.ExecuteTemplate(w, "layout", "") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment