ThePiachu
ThePiachu

Reputation: 9175

Google App Engine Go SDK update problems with template

I`ve just updated my GAE Go SDK to the newest release. I ran the gofix on my code, but there were still some errors. The code used to look:

   AnkietaTemp = template.New(nil)
   err := AnkietaTemp.ParseFile("ankieta/ankieta.html")

but now passing nil doesn't seem to work, so I replaced it into:

   AnkietaTemp = template.New("")
   _, err := AnkietaTemp.ParseFile("ankieta/ankieta.html")

Tried running my app, but in HTML source I get:

 <td width="400"><img src="images/{.section One}{@}{.end}"
alt="images/{.section One}{@}{.end}" width="100%"/></td>

Instead of a neat reference to an image file.

What is the proper way to parse the template files now, after the update?

Upvotes: 0

Views: 488

Answers (1)

macbirdie
macbirdie

Reputation: 16193

In the new template package the template tag syntax changed, as you can see in the documentation. E.g. dot (.) is used instead of @ for referencing the "current" item and the template tags are indicated with two curly braces instead of one.

Edit: Oh, and there's no .section tag any more. You didn't provide the structure you pass to template's Execute() method so I can't provide details on how mitigate that exactly, but I guess you can use {{with}} tag like {{with One}}{.}{{end}} or maybe {{.One}}.

Upvotes: 3

Related Questions