summaryrefslogtreecommitdiff
path: root/_includes/functions/get_value.html
blob: bbd18153db054b25116b5cb6573a874cc469ac34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{%- if include.params.name -%}
  {%- assign name = include.params.name -%}
{%- endif -%}

{%- assign keys = name | split:'.' -%}
{%- assign name = keys.first -%}

{%- if page[name] != nil -%}
  {%- assign return = page[name] -%}
{%- elsif site[name] != nil -%}
  {%- assign return = site[name] -%}
{%- elsif site.data[name] != nil -%}
  {%- assign return = site.data[name] -%}
{%- elsif site.defaults[page.layout][name] != nil -%}
  {%- assign return = site.defaults[page.layout][name] -%}
{%- elsif site.data.defaults[page.layout][name] != nil -%}
  {%- assign return = site.data.defaults[page.layout][name] -%}
{%- elsif layout[name] != nil -%}
  {%- assign return = layout[name] -%}
{%- else -%}
  {%- assign return = include.params.default -%}
{%- endif -%}

{%- assign keys = keys | shift -%}
{%- for key in keys -%}
  {%- assign return = return[key] -%}
  {%- if return == nil -%}
    {%- assign return = include.params.default -%}
    {%- break -%}
  {%- endif -%}
{%- endfor -%}