layouts: tikz: allow using file input

Makes it easier to handle big diagrams.
This commit is contained in:
Bruno BELANYI 2024-07-20 16:20:33 +01:00
parent 189cdcf05a
commit 491041df09

View file

@ -1,3 +1,16 @@
<script type="text/tikz">
{{.Inner}}
{{ with .Get "file" }}
{{ if eq (. | printf "%.1s") "/" }}
{{/* Absolute path are from root of site. */}}
{{ $.Scratch.Set "filepath" . }}
{{ else }}
{{/* Relative paths are from page directory. */}}
{{ $.Scratch.Set "filepath" $.Page.File.Dir }}
{{ $.Scratch.Add "filepath" . }}
{{ end }}
{{ $.Scratch.Get "filepath" | readFile }}
{{ else }}
{{.Inner}}
{{ end }}
</script>