{{/* Table Shortcode for Hugo Blox Builder. */}} {{/* Load a CSV table from page dir falling back back to remote URL */}} {{/* Defaults to expecting a comma-separated CSV with a header row. */}} {{/* Docs: https://docs.hugoblox.com/content/writing-markdown-latex/#csv-table Parameters ---------- src : Path or url to the csv table. Path is relative to the folder where the shortcode is called. delimiter : default "," Field delimiter. header : default "true" If "true", the first row is rendered as the header. caption : optional Caption for the table. */}} {{ $src := .Get "path" }} {{ $delimiter := .Get "delimiter" | default "," }} {{ $useHeaderRow := (eq (lower (.Get "header")) "true") | default true }} {{ $caption := .Get "caption" }} {{ $is_remote := strings.HasPrefix $src "http" }} {{ if not $is_remote }} {{ $src = path.Join "content" $.Page.File.Dir $src }} {{ end }} {{ $rows := getCSV $delimiter $src }} {{ if $useHeaderRow }} {{ $headerRow := index $rows 0 }} {{ $rows = after 1 $rows }} {{ range $headerRow }} {{ end }} {{ end }} {{ range $rows }} {{ range . }} {{ if (findRE "^\\d+$" .) }} {{ else }} {{ end }} {{ end }} {{ end }} {{ if $caption }} {{ end }}
{{ . | markdownify | emojify }}
{{ . }}{{ . | markdownify | emojify }}
{{ $caption | markdownify | emojify }}