summaryrefslogtreecommitdiff
path: root/_includes/functions/get_value.html
blob: 6d9ac81bdf69f6a212b4f83de589297b8a5315f0 (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
33
34
35
36
37
38
39
40
41
42
{%- if include.params.name -%}
  {%- assign name = include.params.name -%}
{%- endif -%}

{%- assign return = nil -%}

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

{%- for step in (1..7) -%}

  {%- case step -%}
    {%- when 1 -%}
      {%- assign return = page[name] -%}
    {%- when 2 -%}
      {%- assign return = site[name] -%}
    {%- when 3 -%}
      {%- assign return = site.data[name] -%}
    {%- when 4 -%}
      {%- assign return = site.defaults[page.layout][name] -%}
    {%- when 5 -%}
      {%- assign return = site.data.defaults[page.layout][name] -%}
    {%- when 6 -%}
      {%- assign return = layout[name] -%}
    {%- else -%}
      {%- assign return = include.params.default -%}
  {%- endcase -%}

  {%- for key in keys -%}
    {%- assign return = return[key] -%}
    {%- if return == nil -%}
      {%- break -%}
    {%- endif -%}
  {%- endfor -%}

  {%- if return != nil -%}
    {%- break -%}
  {%- endif -%}

{%- endfor -%}