From 5f671515504b56d7d1906fa2d17e72de49d84437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sun, 27 Feb 2022 13:36:58 +0100 Subject: [PATCH] tpl/diagrams: Rename Body to Inner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This relates to #9577 – there's no concept a body element in SVG, so we might as well use an exsisting "Hugo term". --- tpl/diagrams/diagrams.go | 12 ++++++++++-- .../_default/_markup/render-codeblock-goat.html | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tpl/diagrams/diagrams.go b/tpl/diagrams/diagrams.go index 1bdbc2a02..b0ddf5a42 100644 --- a/tpl/diagrams/diagrams.go +++ b/tpl/diagrams/diagrams.go @@ -25,9 +25,17 @@ import ( ) type SVGDiagram interface { - Body() template.HTML + // Inner returns the inner markup of the SVG. + // This allows for the container to be created manually. + Inner() template.HTML + + // SVG returns the diagram as an SVG, including the container. SVG() template.HTML + + // Width returns the width of the SVG. Width() int + + // Height returns the height of the SVG. Height() int } @@ -35,7 +43,7 @@ type goatDiagram struct { d goat.SVG } -func (d goatDiagram) Body() template.HTML { +func (d goatDiagram) Inner() template.HTML { return template.HTML(d.d.Body) } diff --git a/tpl/tplimpl/embedded/templates/_default/_markup/render-codeblock-goat.html b/tpl/tplimpl/embedded/templates/_default/_markup/render-codeblock-goat.html index f23fa046e..35ec0b309 100644 --- a/tpl/tplimpl/embedded/templates/_default/_markup/render-codeblock-goat.html +++ b/tpl/tplimpl/embedded/templates/_default/_markup/render-codeblock-goat.html @@ -12,7 +12,7 @@ {{ else }} viewBox="0 0 {{ .Width }} {{ .Height }}" {{ end }}> - {{ .Body }} + {{ .Inner }} {{ end }}