aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/shortcodes/include_range.md
blob: bed515a061ead7adac533a3c9cc87ce66b6228a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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. -#}