From a7d8a2977d6110d1f8778b8ae02067982a5e43a7 Mon Sep 17 00:00:00 2001 From: jeffreytse Date: Tue, 29 Sep 2020 12:54:54 +0800 Subject: fix: some function params not working --- _includes/functions.html | 7 ++++--- _includes/functions/get_datetimes.html | 4 ++-- _includes/functions/get_reading_time.html | 8 ++++---- _includes/functions/get_value.html | 20 ++++++++++---------- _includes/functions/log.html | 8 ++++---- 5 files changed, 24 insertions(+), 23 deletions(-) (limited to '_includes') diff --git a/_includes/functions.html b/_includes/functions.html index 3f9fee2..69e3d5a 100644 --- a/_includes/functions.html +++ b/_includes/functions.html @@ -1,5 +1,6 @@ -{%- if include.func -%} - {%- assign func = include.func -%} +{%- assign params = include -%} +{%- if params.func -%} + {%- assign func = params.func -%} {%- endif -%} {%- assign include_path = func -%} @@ -12,7 +13,7 @@ {%- include functions/log.html level=include.level msg=include.msg -%} {%- else -%} {%- assign include_path = 'functions/' | append: include_path -%} - {%- include {{ include_path }} -%} + {%- include {{ include_path }} params=params-%} {%- endif -%} {%- if func != 'log' -%} diff --git a/_includes/functions/get_datetimes.html b/_includes/functions/get_datetimes.html index 4398fbf..f5b4d7e 100644 --- a/_includes/functions/get_datetimes.html +++ b/_includes/functions/get_datetimes.html @@ -1,5 +1,5 @@ -{% if include.filter %} - {% assign filter = include.filter %} +{% if include.params.filter %} + {% assign filter = include.params.filter %} {% endif %} {% assign split_mark = '<|>' %} diff --git a/_includes/functions/get_reading_time.html b/_includes/functions/get_reading_time.html index d28b69c..7747108 100644 --- a/_includes/functions/get_reading_time.html +++ b/_includes/functions/get_reading_time.html @@ -1,9 +1,9 @@ -{% if include.article %} - {% assign article = include.article %} +{% if include.params.article %} + {% assign article = include.params.article %} {% endif %} -{% if include.speed %} - {% assign speed = include.speed %} +{% if include.params.speed %} + {% assign speed = include.params.speed %} {% else %} {% assign speed = 160 %} {% endif %} diff --git a/_includes/functions/get_value.html b/_includes/functions/get_value.html index 17561a2..5b1dbc4 100644 --- a/_includes/functions/get_value.html +++ b/_includes/functions/get_value.html @@ -1,19 +1,19 @@ -{%- if include.name -%} - {%- assign name = include.name -%} +{%- if include.params.name -%} + {%- assign name = include.params.name -%} {%- endif -%} -{%- assign return = include.return -%} - -{%- if page[name] -%} +{%- if page[name] != nil -%} {%- assign return = page[name] -%} -{%- elsif site[name] -%} +{%- elsif site[name] != nil -%} {%- assign return = site[name] -%} -{%- elsif site.data[name] -%} +{%- elsif site.data[name] != nil -%} {%- assign return = site.data[name] -%} -{%- elsif site.defaults[page.layout][name] -%} +{%- elsif site.defaults[page.layout][name] != nil -%} {%- assign return = site.defaults[page.layout][name] -%} -{%- elsif site.data.defaults[page.layout][name] -%} +{%- elsif site.data.defaults[page.layout][name] != nil -%} {%- assign return = site.data.defaults[page.layout][name] -%} -{%- elsif layout[name] -%} +{%- elsif layout[name] != nil -%} {%- assign return = layout[name] -%} +{%- else -%} + {%- assign return = include.params.default -%} {%- endif -%} diff --git a/_includes/functions/log.html b/_includes/functions/log.html index b2a6130..95d1856 100644 --- a/_includes/functions/log.html +++ b/_includes/functions/log.html @@ -1,9 +1,9 @@ -{% if include.level %} - {% assign level = include.level %} +{% if include.params.level %} + {% assign level = include.params.level %} {% endif %} -{% if include.msg %} - {% assign msg = include.msg %} +{% if include.params.msg %} + {% assign msg = include.params.msg %} {% endif %} {% if site.debug == true %} -- cgit v1.2.3