From 6059b8d8c6085426fce1a6e638af069750c9dd54 Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Sat, 4 Dec 2021 18:30:54 +0100 Subject: added virtio post --- templates/shortcodes/include_range.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 templates/shortcodes/include_range.md (limited to 'templates/shortcodes') 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. #} -- cgit v1.2.3