From 53273c1d55522b6b9c909ddff15be5dc56fc0999 Mon Sep 17 00:00:00 2001 From: Francesc Campoy Date: Thu, 2 Jan 2014 16:03:56 -0800 Subject: [PATCH] go.tools: Expose filename rather than extension only, needed for new tour. R=adg, r CC=golang-codereviews https://golang.org/cl/43470050 --- present/code.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/present/code.go b/present/code.go index de15543109..cc1e45e50d 100644 --- a/present/code.go +++ b/present/code.go @@ -29,10 +29,11 @@ func init() { } type Code struct { - Text template.HTML - Play bool // runnable code - Ext string // file extension - Raw []byte // content of the file + Text template.HTML + Play bool // runnable code + FileName string // file name + Ext string // file extension + Raw []byte // content of the file } func (c Code) TemplateName() string { return "code" } @@ -128,10 +129,11 @@ func parseCode(ctx *Context, sourceFile string, sourceLine int, cmd string) (Ele return nil, err } return Code{ - Text: template.HTML(buf.String()), - Play: play, - Ext: filepath.Ext(filename), - Raw: textBytes, + Text: template.HTML(buf.String()), + Play: play, + FileName: filepath.Base(filename), + Ext: filepath.Ext(filename), + Raw: textBytes, }, nil }