github.com/aleksi/gonuts.io@v0.0.0-20130622121132-3b0f2d1999fb/app/gonuts/controllers/doc.go (about)

     1  package controllers
     2  
     3  import (
     4  	"appengine"
     5  	"bytes"
     6  	"fmt"
     7  	"html/template"
     8  	"net/http"
     9  
    10  	"gonuts"
    11  )
    12  
    13  func docHandler(c appengine.Context, w http.ResponseWriter, r *http.Request) {
    14  	var content bytes.Buffer
    15  
    16  	section := r.URL.Query().Get(":section")
    17  	file := "doc.html"
    18  	if section != "" {
    19  		file = fmt.Sprintf("doc_%s.html", section)
    20  	}
    21  	gonuts.PanicIfErr(Base.ExecuteTemplate(&content, file, ""))
    22  
    23  	bd := BaseData{
    24  		Tabtitle: "Documentation",
    25  		Title:    "Documentation",
    26  		Content:  template.HTML(content.String()),
    27  	}
    28  	gonuts.PanicIfErr(Base.Execute(w, &bd))
    29  }