HTML comments
Closed this issue · 5 comments
tabula-rasa commented
Good day, really like your work, but is there any possibility to write html comments in gold, e.g.:
Thank you!
yosssi commented
@tabula-rasa
I'm so sorry but there are no features to write html comments in Gold for now. I'll try to think of the way to implement this feature.
For now, you can write html comments by writing such following code:
main.go
package main
import (
"html/template"
"net/http"
"github.com/yosssi/gold"
)
func handler(w http.ResponseWriter, r *http.Request) {
g := gold.NewGenerator(false)
tpl, err := g.ParseFile("./top.gold")
if err != nil {
panic(err)
}
data := map[string]interface{}{
"Script": template.HTML(`
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<![endif]-->
`),
}
tpl.Execute(w, data)
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}
top.gold
doctype html
html lang=en
head
title Hello Gold!
= .Script
body
h1 Gold - Template engine for Go
tabula-rasa commented
Thank you!
yosssi commented
@tabula-rasa
Hi,
As I announced at #24, I re-created Gold as a new package.
Ace - HTML template engine for Go
Please check this package.
You can write HTML conditional comments easily by using this package. (See this document.)
Thanks.
tabula-rasa commented
Good news :)
I will use ace engine in my next projects, thank you!
yosssi commented
You're welcome!