From d9298a35b6741a918e21e5d04e742f05b784e3ea Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Sat, 2 Feb 2019 12:30:56 +0100 Subject: blogc: added template variables for memory and cpu time resource usage this include infrastructure required to have variables evaluated as lazy function calls. missing tests, docs and improvements. --- src/blogc/renderer.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/blogc/renderer.c') diff --git a/src/blogc/renderer.c b/src/blogc/renderer.c index 6a591ec..2326e09 100644 --- a/src/blogc/renderer.c +++ b/src/blogc/renderer.c @@ -12,6 +12,7 @@ #include #include #include "datetime-parser.h" +#include "funcvars.h" #include "template-parser.h" #include "renderer.h" #include "../common/error.h" @@ -101,10 +102,15 @@ blogc_format_variable(const char *name, bc_trie_t *global, bc_trie_t *local, } if ((0 == strcmp(var, "FOREACH_ITEM")) && - (foreach_var != NULL && foreach_var->data != NULL)) + (foreach_var != NULL && foreach_var->data != NULL)) { value = foreach_var->data; - else - value = blogc_get_variable(var, global, local); + } + else { + value = blogc_funcvars_lookup(var, global); + if (value == NULL) { + value = blogc_get_variable(var, global, local); + } + } if (value == NULL) { free(var); -- cgit v1.2.3-18-g5258