Exemplo n.º 1
0
func saveHandler(ctx *web.Context, title string) {
	body, ok := ctx.Request.Params["body"]
	if !ok {
		ctx.Abort(500, "No body supplied.")
		return
	}
	page := makePage(title, string(body))
	page.save()
	redirect(ctx, "view", title)
}
Exemplo n.º 2
0
func renderTmpl(ctx *web.Context, tmpl, title, body string) {
	d := map[string]string{
		"prefix": urlPrefix,
		"title":  title,
		"body":   body,
	}
	t, err := template.ParseFile("tmpl/"+tmpl+".html", nil)
	if err != nil {
		ctx.Abort(500, "Unable to Parse template file: "+err.String())
		return
	}
	err = t.Execute(ctx, d)
	if err != nil {
		ctx.Abort(500, "Unable to Execute template: "+err.String())
	}
}