From fcdfc7ea09f0e0d191772650b4f197aa8f56355a Mon Sep 17 00:00:00 2001 From: jeffreytse Date: Fri, 8 Jan 2021 11:51:40 +0800 Subject: feat: support dict object for `get_value` function --- _includes/functions/get_value.html | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to '_includes/functions') 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 -%} + -- cgit v1.2.3