aboutsummaryrefslogtreecommitdiffstats
path: root/src/renderer.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2015-04-23 19:44:39 -0300
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2015-04-23 19:44:39 -0300
commit7582a32c837c8b55613b547799d1a6405e926cba (patch)
tree91d1c6cd950b685ac29ab7b555b73ee7da2a04dd /src/renderer.c
parentc7241b7dba557674ae84f53bcf55cd8597be3559 (diff)
downloadblogc-7582a32c837c8b55613b547799d1a6405e926cba.tar.gz
blogc-7582a32c837c8b55613b547799d1a6405e926cba.tar.bz2
blogc-7582a32c837c8b55613b547799d1a6405e926cba.zip
template parser: added "if not" support
Diffstat (limited to 'src/renderer.c')
-rw-r--r--src/renderer.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/renderer.c b/src/renderer.c
index 69206c3..92fa7d4 100644
--- a/src/renderer.c
+++ b/src/renderer.c
@@ -34,6 +34,8 @@ blogc_render(b_slist_t *tmpl, b_slist_t *sources, bool listing)
unsigned int if_count = 0;
unsigned int if_skip = 0;
+ bool if_not = false;
+
b_slist_t *tmp = tmpl;
while (tmp != NULL) {
blogc_template_stmt_t *stmt = tmp->data;
@@ -104,9 +106,14 @@ blogc_render(b_slist_t *tmpl, b_slist_t *sources, bool listing)
}
break;
+ case BLOGC_TEMPLATE_IF_NOT_STMT:
+ if_not = true;
+
case BLOGC_TEMPLATE_IF_STMT:
if (stmt->value != NULL && tmp_source != NULL) {
- if (b_trie_lookup(tmp_source, stmt->value) == NULL) {
+ if ((!if_not && (b_trie_lookup(tmp_source, stmt->value) == NULL)) ||
+ (if_not && (b_trie_lookup(tmp_source, stmt->value) != NULL)))
+ {
if_skip = if_count;
// at this point we can just skip anything, counting the
@@ -115,7 +122,9 @@ blogc_render(b_slist_t *tmpl, b_slist_t *sources, bool listing)
while (1) {
tmp = tmp->next;
stmt = tmp->data;
- if (stmt->type == BLOGC_TEMPLATE_IF_STMT) {
+ if ((stmt->type == BLOGC_TEMPLATE_IF_STMT) ||
+ (stmt->type == BLOGC_TEMPLATE_IF_NOT_STMT))
+ {
if_count++;
continue;
}
@@ -129,6 +138,7 @@ blogc_render(b_slist_t *tmpl, b_slist_t *sources, bool listing)
}
}
}
+ if_not = false;
}
break;