diff --git a/example_config/example.config b/example_config/example.config index 9e911c7..b7328bd 100644 --- a/example_config/example.config +++ b/example_config/example.config @@ -36,6 +36,29 @@ HTML=''' {{{!ENDIF}}} {{{!ENDFOREACH}}} +Again with IFs:
+ +{{{!IF EachIfTest_Array[0]==true}}} + EachIfTest_Array entry is true.
+{{{!ELSE}}} + EachIfTest_Array entry is false.
+{{{!ENDIF}}} +{{{!IF EachIfTest_Array[1]==true}}} + EachIfTest_Array entry is true.
+{{{!ELSE}}} + EachIfTest_Array entry is false.
+{{{!ENDIF}}} +{{{!IF EachIfTest_Array[2]==true}}} + EachIfTest_Array entry is true.
+{{{!ELSE}}} + EachIfTest_Array entry is false.
+{{{!ENDIF}}} +{{{!IF EachIfTest_Array[3]==true}}} + EachIfTest_Array entry is true.
+{{{!ELSE}}} + EachIfTest_Array entry is false.
+{{{!ENDIF}}} +

Test IF/FOREACH Expr

diff --git a/src/http_template.c b/src/http_template.c index 6d0cb57..ef17aeb 100644 --- a/src/http_template.c +++ b/src/http_template.c @@ -229,10 +229,12 @@ int c_simple_http_internal_parse_if_expression( fprintf(stderr, "ERROR No closing \"]\"! %s\n", var); return 1; } else if ( - idx + 1 < var_size && var[idx] == '!' && var[idx + 1] == '=') { + idx + 2 < var_size && var[idx + 1] == '!' && var[idx + 2] == '=') { + ++idx; break; } else if ( - idx + 1 < var_size && var[idx] == '=' && var[idx + 1] == '=') { + idx + 2 < var_size && var[idx + 1] == '=' && var[idx + 2] == '=') { + ++idx; break; } else { fprintf(stderr, "ERROR Invalid expression after \"]\"! %s\n", var);