summaryrefslogtreecommitdiff
path: root/themes/tabi-lean/templates/shortcodes/remote_text.html
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2025-09-13 14:55:15 -0600
committerAlejandro Soto <alejandro@34project.org>2025-09-13 14:55:15 -0600
commit87f85704af1fa866be83077b2b351c1fdad7c3ce (patch)
treeb49c8d49ef717e539bff6578992e692eea55d380 /themes/tabi-lean/templates/shortcodes/remote_text.html
parent1a4c3216f027d6a6f36104547377b7b21faa5015 (diff)
parenta2ea06d513a5802964f8f0ef5795cec7e548ed7b (diff)
Merge commit 'a2ea06d513a5802964f8f0ef5795cec7e548ed7b' as 'themes/tabi-lean'
Diffstat (limited to 'themes/tabi-lean/templates/shortcodes/remote_text.html')
-rw-r--r--themes/tabi-lean/templates/shortcodes/remote_text.html30
1 files changed, 30 insertions, 0 deletions
diff --git a/themes/tabi-lean/templates/shortcodes/remote_text.html b/themes/tabi-lean/templates/shortcodes/remote_text.html
new file mode 100644
index 0000000..70fd33a
--- /dev/null
+++ b/themes/tabi-lean/templates/shortcodes/remote_text.html
@@ -0,0 +1,30 @@
+{%- set start = start | default(value=1) -%}
+{%- set end = end | default(value=0) -%}
+
+{#- load_data uses different arguments based on whether it's a remote or local file -#}
+{%- if src is starting_with("http") -%}
+ {%- set response = load_data(url=src, format="plain") -%}
+{%- else -%}
+ {#- Try to load the file from a relative path -#}
+ {%- set colocated_path = page.colocated_path | default(value="") -%}
+ {%- set relative_path = colocated_path ~ src -%}
+ {%- set response = load_data(path=relative_path, format="plain", required=false) -%}
+ {#- If relative path fails, try absolute path -#}
+ {%- if not response -%}
+ {%- set response = load_data(path=src, format="plain") -%}
+ {%- endif -%}
+{%- endif -%}
+
+{%- set lines = response | trim_end | split(pat="\n") -%}
+
+{%- if start > 0 -%}
+ {%- set start = start - 1 -%}
+{%- endif -%}
+
+{%- if end == 0 or end > lines | length -%}
+ {%- set end = lines | length -%}
+{%- endif -%}
+
+{%- set lines = lines | slice(start=start, end=end) -%}
+
+{{- lines | join(sep="\n") | safe -}}