From af907d66fd4c13ee12f4f2ff1b6c45400929e3b7 Mon Sep 17 00:00:00 2001
From: Michael Currin <18750745+MichaelCurrin@users.noreply.github.com>
Date: Tue, 10 Sep 2024 10:46:54 +0200
Subject: [PATCH] Update table.md
---
cheatsheets/jekyll/templating/table.md | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/cheatsheets/jekyll/templating/table.md b/cheatsheets/jekyll/templating/table.md
index 98ce027b0..ca0d9c4a2 100644
--- a/cheatsheets/jekyll/templating/table.md
+++ b/cheatsheets/jekyll/templating/table.md
@@ -109,7 +109,7 @@ Given CSV file:
{% for author in site.data.authors %}
{{ author['First name'] }} |
- {{ author['First name'] }} |
+ {{ author['Last name'] }} |
{{ author['Age'] }} |
{{ author['Location'] }} |
@@ -120,9 +120,10 @@ Given CSV file:
### Dynamic table
-This approach is more flexible - it will work for any CSV and render all columns without having to reference them specifically.
+Notes:
-Data is unpacked as a tuple of keys and values for each row, so we name this `pair` and slice it. Also note use of dynamic header - we read the column names for the first row.
+- Here using the `tablerow` builtin Liquid method to render a row. No need to add `tbody`, `tr`, or `td` elements for the rows. Note data is unpacked as a tuple of keys and values for each row, so we name this `pair` and slice it.
+- By using a inner `for` loops for the header and data rows, this approach is more flexible - it will work for any CSV and render all columns without having to reference them specifically.
```liquid
{% assign rows = site.data.authors %}
@@ -144,4 +145,10 @@ Data is unpacked as a tuple of keys and values for each row, so we name this `pa
```
+Since this is dynamic, you can easily move it to an `includes` file and then pass data to it and reference as:
+
+```liquid
+{% assign rows = includes.authors %}
+```
+
{% endraw %}