Note that there are some explanatory texts on larger screens.

plurals
  1. POGolang GAE - intID in struct for mustache
    primarykey
    data
    text
    <p>Here is an <a href="https://www.dropbox.com/sh/ur2ws1jnik6euef/PjVJSwDTUc/Blog-Golang.zip">Example</a> of the app. The essential code is in: golang-code/handler/handler.go (After the subject should appear an ID!)</p> <p>Im trying to build a little blog system in Golang on Google Appengine and use Mustache as template engine.</p> <p>So, i have a struct: </p> <pre><code>type Blogposts struct { PostTitle string PostPreview string Content string Creator string Date time.Time } </code></pre> <p>The data is passed to GAE via </p> <pre><code> datastore.Put(c, datastore.NewIncompleteKey(c, "Blogposts", nil), &amp;blogposts) </code></pre> <p>So, GAE assigns automatically a intID (int64). Now I tried to get the latest blogposts</p> <pre><code>// Get the latest blogposts c := appengine.NewContext(r) q := datastore.NewQuery("Blogposts").Order("-Date").Limit(10) var blogposts []Blogposts _, err := q.GetAll(c, &amp;blogposts) </code></pre> <p>Until there all things works fine, but when I try to access intID (or stringID, whatever) I dont have access to this :-(</p> <pre><code>&lt;h3&gt;&lt;a href="/blog/read/{{{intID}}}"&gt;{{{PostTitle}}}&lt;/a&gt;&lt;/h3&gt; </code></pre> <p>(PostTitle works, intID not, i've tried thousand of things, nothing worked :-( )</p> <p>Anyone an idea? This would be great!</p> <p>Edit: I use mustache.</p> <p><a href="http://mustache.github.com/">http://mustache.github.com/</a></p> <p>In the code I use:</p> <pre><code>x["Blogposts"] = blogposts data := mustache.RenderFile("templates/about.mustache", x) sendData(w, data) // Equivalent to fmt.Fprintf </code></pre> <p>And then the data can be accessed in the .mustache template with {{{Content}}} or {{{PostTitle}}} etc. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload