Skip to content

Commit

Permalink
tpl/diagrams: Rename Body to Inner
Browse files Browse the repository at this point in the history
This relates to #9577 – there's no concept a body element in SVG, so we might as well use an exsisting "Hugo term".
  • Loading branch information
bep committed Feb 27, 2022
1 parent f710977 commit 5f67151
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions tpl/diagrams/diagrams.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,25 @@ import (
)

type SVGDiagram interface {
Body() template.HTML
// Inner returns the inner markup of the SVG.
// This allows for the <svg> container to be created manually.
Inner() template.HTML

// SVG returns the diagram as an SVG, including the <svg> container.
SVG() template.HTML

// Width returns the width of the SVG.
Width() int

// Height returns the height of the SVG.
Height() int
}

type goatDiagram struct {
d goat.SVG
}

func (d goatDiagram) Body() template.HTML {
func (d goatDiagram) Inner() template.HTML {
return template.HTML(d.d.Body)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{{ else }}
viewBox="0 0 {{ .Width }} {{ .Height }}"
{{ end }}>
{{ .Body }}
{{ .Inner }}
</svg>
{{ end }}
</div>

0 comments on commit 5f67151

Please sign in to comment.