blog/_includes/functions/get_value.html

33 lines
988 B
HTML
Raw Normal View History

2020-09-29 06:54:54 +02:00
{%- if include.params.name -%}
{%- assign name = include.params.name -%}
2019-09-11 06:19:34 +02:00
{%- endif -%}
2021-06-17 12:57:37 +02:00
{%- assign keys = name | split:'.' -%}
{%- assign name = keys.first -%}
2020-09-29 06:54:54 +02:00
{%- if page[name] != nil -%}
2019-09-11 06:19:34 +02:00
{%- assign return = page[name] -%}
2020-09-29 06:54:54 +02:00
{%- elsif site[name] != nil -%}
{%- assign return = site[name] -%}
2020-09-29 06:54:54 +02:00
{%- elsif site.data[name] != nil -%}
2019-09-11 06:19:34 +02:00
{%- assign return = site.data[name] -%}
2020-09-29 06:54:54 +02:00
{%- elsif site.defaults[page.layout][name] != nil -%}
2019-09-11 06:19:34 +02:00
{%- assign return = site.defaults[page.layout][name] -%}
2020-09-29 06:54:54 +02:00
{%- elsif site.data.defaults[page.layout][name] != nil -%}
2019-09-11 06:19:34 +02:00
{%- assign return = site.data.defaults[page.layout][name] -%}
2020-09-29 06:54:54 +02:00
{%- elsif layout[name] != nil -%}
2019-09-11 06:19:34 +02:00
{%- assign return = layout[name] -%}
2020-09-29 06:54:54 +02:00
{%- else -%}
{%- assign return = include.params.default -%}
2019-09-11 06:19:34 +02:00
{%- endif -%}
{%- assign keys = keys | shift -%}
{%- for key in keys -%}
{%- assign return = return[key] -%}
{%- if return == nil -%}
{%- assign return = include.params.default -%}
{%- break -%}
{%- endif -%}
{%- endfor -%}