templates/file.go (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | package templates import ( "fmt" g "go.alanpearce.eu/gomponents" . "go.alanpearce.eu/gomponents/html" ) // File renders a file view page func File(data PageData, chroma bool) g.Node { return Page(data, []g.Node{ RepoHeader(data), RenderNav(data), Main( P(g.Text(data.Path), g.Text(" ("), A(Href("?raw=true"), g.Text("view raw")), g.Text(")")), g.If(chroma, Div(Class("chroma-file-wrapper"), g.Raw(data.Content)), Div(Class("file-wrapper"), Table( TBody( Tr( Td(Class("line-numbers"), Pre(g.Map(data.LineCount, func(line int) g.Node { return g.Group([]g.Node{ g.Text("\n"), A( ID(fmt.Sprintf("L%d", line)), Href(fmt.Sprintf("#L%d", line)), g.Text(fmt.Sprintf("%d", line)), )}) })), ), Td(Class("file-content"), Pre(g.Text(data.Content)), ), ), ), ), ), ), ), }) } |