go-templates Questions

2

Solved

I'm building go web application. I found some anomaly on the rendered html page. All of my html comments <!-- --> are suddenly not being rendered. My guess it's because the go version I used ...
Semite asked 18/12, 2015 at 3:24

1

Solved

How can I do in Golang if I have an HTML file like this: <html> <head lang="en"> </head> <body> <header>{{.Header}}</header> <div class="panel panel-d...
Humeral asked 29/11, 2015 at 14:56

2

Solved

Go templates have some unexpected results when using eq with index for me. See this code: package main import ( "os" "text/template" ) func main() { const myTemplate = ` {{range $n := .}} {{...
Terina asked 22/10, 2015 at 13:21

3

Solved

is there any way to pass just a variable (string, int, bool) into template. For example (something similar): import ( "html/template" ) func main() { .... tmpl := template.Must(template.ParseF...
Marrowfat asked 15/1, 2015 at 19:16

1

Say I have a html/template like the following: <html> <body> <p>{{SomeFunc .SomeData}}</p> </body> and sometimes SomeFunc returns an error. Is there an idiomatic w...
Shackleford asked 13/6, 2015 at 17:49

1

The use of if statements inside templates really is puzzling me. I'm trying to put a class = "active" inside a nav list made with golang templates, to do a basic tab menu that detects the active t...
Nineveh asked 15/7, 2014 at 10:12

1

Solved

We can define template name via {{define "home"}}, and then load it in other (parent) template via {{template "home"}}. How I can load template via variable value {{template .TemplateName}}. Or it...
Cryptocrystalline asked 3/3, 2015 at 11:21

2

I have a Golang array I'm passing to my html file on the front end. I know that '{{ index .Array 0}}' works and pulls the first element from the array. But I want to do a Javascript for-loop ...
Nosegay asked 26/2, 2015 at 19:59

1

It is so slow when using template package to generate a dynamic web page to client. Testing code as below, golang 1.4.1 http.Handle("/js/", (http.FileServer(http.Dir(webpath)))) http.Handle("/cs...
Subhuman asked 11/2, 2015 at 10:15

1

Solved

I'm currently working in Go. I created a web server on my local machine. I followed the instruction on this page Rendering CSS in a Go Web Application but I'm still getting the 404 error that the p...
Atkins asked 3/2, 2015 at 7:25

1

Solved

How do I unescape html? I'm passing a css file into html like this <style>{{.file}}</style> I get this <style>ZgotmplZ</style> I've tried wrapping the field with temp...
Surface asked 12/1, 2015 at 16:45

1

Solved

Struct methods in Go templates are usually called same way as public struct properties but in this case it just doesn't work: http://play.golang.org/p/xV86xwJnjA {{with index . 0}} {{.FirstName}}...
Sacker asked 5/12, 2014 at 22:15

2

Solved

I am trying to display a list gym classes (Yoga, Pilates etc). For each class type there are several classes, so I want to group all the Yoga classes, and all the Pilates classes and so on. I made...
Knowlton asked 23/1, 2014 at 8:1

1

Solved

Playground link: http://play.golang.org/p/Ebf5AuJlcP type Foo interface {} type Bar interface { ThisIsABar() } // Person implements both Foo and Bar type Person struct { Name string } func (p...
Diez asked 30/10, 2013 at 21:31

1

Solved

Is it possible, within a {{range pipeline}} T1 {{end}} action in the text/template package to access the pipelines value prior to the range action, or the parent/global pipeline passed as an argume...
Gebler asked 24/6, 2013 at 20:11

2

Solved

When inside a with or range, the scope of . is changed. How do you access the calling scope?
Vernalize asked 10/2, 2013 at 17:3

2

Solved

For example.go, I have package main import "html/template" import "net/http" func handler(w http.ResponseWriter, r *http.Request) { t, _ := template.ParseFiles("header.html", "footer.html") t....
Koroseal asked 1/9, 2012 at 2:30

2

Solved

I have a slice: Keys []* datastore.Key How could I index one of them in the template file? I guessed {{.Keys[3] }}, but that doesn't work and I searched a lot but with no clue. Any suggestions wo...
Chaiken asked 3/10, 2012 at 3:24

© 2022 - 2024 — McMap. All rights reserved.