summaryrefslogtreecommitdiff
path: root/_includes/functions/get_value.html
diff options
context:
space:
mode:
authorjeffreytse <jeffreytse.mail@gmail.com>2021-01-08 11:51:40 +0800
committerjeffreytse <jeffreytse.mail@gmail.com>2021-01-08 11:51:40 +0800
commitfcdfc7ea09f0e0d191772650b4f197aa8f56355a (patch)
tree93daa27b7b9f6c31ac02d06578dfecf25d1d4ef6 /_includes/functions/get_value.html
parentb8ed37973e85eb19b461a32f5c5fa775d74d4e1a (diff)
feat: support dict object for `get_value` function
Diffstat (limited to '_includes/functions/get_value.html')
-rw-r--r--_includes/functions/get_value.html13
1 files changed, 13 insertions, 0 deletions
diff --git a/_includes/functions/get_value.html b/_includes/functions/get_value.html
index 5b1dbc4..d1d8507 100644
--- a/_includes/functions/get_value.html
+++ b/_includes/functions/get_value.html
@@ -2,6 +2,9 @@
{%- 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 -%}
@@ -17,3 +20,13 @@
{%- 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 -%}
+