1
0
mirror of https://github.com/golang/go synced 2024-09-30 16:18:35 -06:00

go.tools/present: add extension name to Code

This will be used to show the "Run" button for code snippets in go.talks only for Go when running on App Engine.

R=adg, r, iant
CC=golang-dev
https://golang.org/cl/21930047
This commit is contained in:
Francesc Campoy 2013-11-06 13:02:20 -08:00
parent 6df4bd0406
commit 2c650d6a84

View File

@ -31,6 +31,7 @@ func init() {
type Code struct {
Text template.HTML
Play bool // runnable code
Ext string // file extension
}
func (c Code) TemplateName() string { return "code" }
@ -125,7 +126,11 @@ func parseCode(ctx *Context, sourceFile string, sourceLine int, cmd string) (Ele
if err := codeTemplate.Execute(&buf, data); err != nil {
return nil, err
}
return Code{Text: template.HTML(buf.String()), Play: play}, nil
return Code{
Text: template.HTML(buf.String()),
Play: play,
Ext: filepath.Ext(filename),
}, nil
}
type codeTemplateData struct {