diff options
author | Johannes Stoelp <johannes.stoelp@gmail.com> | 2021-12-04 18:30:54 +0100 |
---|---|---|
committer | Johannes Stoelp <johannes.stoelp@gmail.com> | 2021-12-04 18:30:54 +0100 |
commit | 6059b8d8c6085426fce1a6e638af069750c9dd54 (patch) | |
tree | 747ef72fda3b32405f90084d8f00f9d2d6163b07 /templates | |
parent | c8a1ac71ce7e5c0183840513fb7bd2d642ca887e (diff) | |
download | blog-6059b8d8c6085426fce1a6e638af069750c9dd54.tar.gz blog-6059b8d8c6085426fce1a6e638af069750c9dd54.zip |
added virtio post
Diffstat (limited to 'templates')
-rw-r--r-- | templates/shortcodes/include_range.md | 17 |
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. #} |