Here is an example application. The main code is in: golang-code / handler / handler.go (after the object should appear ID!)
I am trying to create a small blog system in the Golang on Google Appengine and use Mustache as a template engine.
So I have a structure:
type Blogposts struct { PostTitle string PostPreview string Content string Creator string Date time.Time }
Data is transmitted to GAE through
datastore.Put(c, datastore.NewIncompleteKey(c, "Blogposts", nil), &blogposts)
So GAE automatically assigns an intID (int64). Now I tried to get the latest blog pages
// Get the latest blogposts c := appengine.NewContext(r) q := datastore.NewQuery("Blogposts").Order("-Date").Limit(10) var blogposts []Blogposts _, err := q.GetAll(c, &blogposts)
So far, everything is working fine, but when I try to access the intID (or stringID, regardless), I do not have access to this: - (
<h3><a href="/blog/read/{{{intID}}}">{{{PostTitle}}}</a></h3>
(PostTitle works, no intID, I tried thousands of things, nothing worked :-()
Any idea? It would be great!
Edit: I use a mustache.
http://mustache.github.com/
In the code I'm using:
x["Blogposts"] = blogposts data := mustache.RenderFile("templates/about.mustache", x) sendData(w, data)
And then you can access the data in the .mustache template with {{{Content}}} or {{{PostTitle}}}, etc.