From 44819d4299eed8b74af856f06f043f0bc701bac0 Mon Sep 17 00:00:00 2001 From: Bevan Stanely <60595515+bevsxyz@users.noreply.github.com> Date: Sat, 7 Aug 2021 17:52:32 +0530 Subject: [PATCH] feat: add Table shortcode to render a CSV (#2393) --- wowchemy/layouts/shortcodes/table.html | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 wowchemy/layouts/shortcodes/table.html diff --git a/wowchemy/layouts/shortcodes/table.html b/wowchemy/layouts/shortcodes/table.html new file mode 100644 index 00000000..41730879 --- /dev/null +++ b/wowchemy/layouts/shortcodes/table.html @@ -0,0 +1,36 @@ +{{/* Table Shortcode for Wowchemy. */}} +{{/* Load table from page dir falling back back to remote URL */}} +{{/* Supports delimiter separated files. The default delimiter is ',' */}} + +{{ $src := .Get "src" }} +{{ $delimiter := .Get "delimiter" | default "," }} +{{ $useHeaderRow := .Get "header" | 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 }} + +
| {{ . | markdownify | emojify }} | {{ end }}|
|---|---|
| {{ . }} | + {{ else }} +{{ . | markdownify | emojify }} | + {{ end }} + {{ end }} +