I'm thinking about creating syntax highlighter for it, but I don't know the conventional abbreviation for this specific type of template.
Since you're writing the highlighter just go with what you normally use. I'm sure the community will give you feedback and eventually some sort of agreement.
As for myself, I'm using .thtml
for template html.
In one of the examples from the text/template godoc, they refer to ".tmpl" files.
If you're using the Atom editor with the go-plus plugin, it provides nice syntax highlighting if you use the .gohtml
extension.
I'm using .html.tmpl
. That makes it clear that it's a Go template which will be rendered to HTML. Furthermore, it follows the convention set by other file types like .tar.gz
.
.ext.tmpl is probably the least bad option based on my analysis of stats from one large codebase that includes quite a bit of Go code.
Proportion of files with one of the extensions (.tpl, .tmpl, .html.tmpl, .html.tpl, .thtml) that contain the pattern /[{][{](-\ )?end
/.
.thtml 0%
.gohtml < 1%
.tpl 14%
.tmpl 85%
This misses simpler go templates that do not use loops or conditionals, but not in a way that should skew results.
About a third of the .tmpl
files have the form .
ext.tmpl
of which .html.tmpl
is the single most common. A visual inspection of files sampled from within this show that the extension is an accurate description of the output of the file.
Neither the suffix .tpl
nor .tmpl
is used exclusively for Go templates within this codebase which has a lot of code that predates the Go language. I haven't investigated carefully, but I think it's safe to say that for each of (.tpl
, .tmpl
), the majority of files with that extension are probably not Go templates.
The html/template package uses .tmpl
in their example.
My vote goes to .html.tmpl