aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/shortcodes/include_range.md
diff options
context:
space:
mode:
Diffstat (limited to 'templates/shortcodes/include_range.md')
-rw-r--r--templates/shortcodes/include_range.md17
1 files changed, 17 insertions, 0 deletions
diff --git a/templates/shortcodes/include_range.md b/templates/shortcodes/include_range.md
new file mode 100644
index 0000000..cfcce76
--- /dev/null
+++ b/templates/shortcodes/include_range.md
@@ -0,0 +1,17 @@
+{# Args: #}
+{# path - file to load #}
+{# start - start line #}
+{# end - end line #}
+{# #}
+{# Example: #}
+{# {{ include_range(path="..", start=1, end=2) }} #}
+
+{% set data = load_data(path=path) | split(pat="\n") | slice(start=start-1, end=end) %}
+{% for line in data -%}
+ {{ line }}
+{% endfor %}
+
+{# The '-' in the for loop is important, it removes the whitespaces after the stmt. #}
+{# See: https://tera.netlify.app/docs/#whitespace-control #}
+
+{# Note: I wasn't able to pull this off with a join(), maybe I'll debug one day. #}