From 245768fa061292ced997e5ad4f40c44a477faf35 Mon Sep 17 00:00:00 2001 From: matthes Date: Wed, 26 Jul 2017 18:08:38 +0200 Subject: [PATCH 1/5] Added Test for if/else --- test/unit/tpls/07_if_else/_in.php | 5 +++++ test/unit/tpls/07_if_else/_in.txt | 12 ++++++++++++ test/unit/tpls/07_if_else/out.txt | 5 +++++ 3 files changed, 22 insertions(+) create mode 100644 test/unit/tpls/07_if_else/_in.php create mode 100644 test/unit/tpls/07_if_else/_in.txt create mode 100644 test/unit/tpls/07_if_else/out.txt diff --git a/test/unit/tpls/07_if_else/_in.php b/test/unit/tpls/07_if_else/_in.php new file mode 100644 index 0000000..162d97a --- /dev/null +++ b/test/unit/tpls/07_if_else/_in.php @@ -0,0 +1,5 @@ + TRUE +]; \ No newline at end of file diff --git a/test/unit/tpls/07_if_else/_in.txt b/test/unit/tpls/07_if_else/_in.txt new file mode 100644 index 0000000..4a34bb0 --- /dev/null +++ b/test/unit/tpls/07_if_else/_in.txt @@ -0,0 +1,12 @@ +1: Start +{if boolVal == TRUE} +2: Boolean is true +{else} +3: Some Line of Code +{/if} +{if boolVal == FALSE} +4: Boolean is true +{else} +5: Some Line of Code +{/if} +6: Some other text \ No newline at end of file diff --git a/test/unit/tpls/07_if_else/out.txt b/test/unit/tpls/07_if_else/out.txt new file mode 100644 index 0000000..f8b3cc5 --- /dev/null +++ b/test/unit/tpls/07_if_else/out.txt @@ -0,0 +1,5 @@ +1: Some Value +2: 1.234 +2: Boolean is true +3: Some Line of Code +5: Some other text \ No newline at end of file From 1e08b933a461fe34c9b009a73d7218db5265ca8f Mon Sep 17 00:00:00 2001 From: matthes Date: Wed, 26 Jul 2017 18:52:17 +0200 Subject: [PATCH 2/5] Added else construction --- .gitignore | 1 + README.md | 22 ++++++- src/TextTemplate.php | 103 ++++++++++++++++++++---------- test/templates.phpt | 4 ++ test/unit/tpls/07_if_else/out.txt | 6 +- 5 files changed, 100 insertions(+), 36 deletions(-) diff --git a/.gitignore b/.gitignore index f417e74..e26f5d7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /.idea /vendor +/test/output \ No newline at end of file diff --git a/README.md b/README.md index ccccba1..644f186 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,14 @@ TextTemplate supports infinite-nested loops and sequences. // 1. Define the Template $tplStr = << diff --git a/src/TextTemplate.php b/src/TextTemplate.php index 2e78a43..d4824d6 100644 --- a/src/TextTemplate.php +++ b/src/TextTemplate.php @@ -89,6 +89,20 @@ public function addFilter ($filterName, callable $filterFn) { } + public function _replaceElseIf ($input) { + $lines = explode("\n", $input); + for ($li=0; $li < count ($lines); $li++) { + $lines[$li] = preg_replace_callback('/\{else\}/im', + function ($matches) use (&$nestingIndex, &$indexCounter, &$li) { + return "{/if}{if ::NL_ELSE_FALSE}"; + }, + $lines[$li] + ); + + } + return implode ("\n", $lines); + } + /** * Tag-Nesting is done by initially adding an index to both the opening and the * closing tag. (By the way some cleanup is done) @@ -266,58 +280,83 @@ private function _getItemValue ($compName, $context) { } - private function _runIf ($context, $content, $cmdParam, $softFail=TRUE) { + private function _runIf ($context, $content, $cmdParam, $softFail=TRUE, &$ifConditionDidMatch) { //echo $cmdParam; - if ( ! preg_match('/([\"\']?.*?[\"\']?)\s*(==|<|>|!=)\s*([\"\']?.*[\"\']?)/i', $cmdParam, $matches)) - return "!! Invalid command sequence: '$cmdParam' !!"; - - //print_r ($matches); - - $comp1 = $this->_getItemValue(trim ($matches[1]), $context); - $comp2 = $this->_getItemValue(trim ($matches[3]), $context); - - //decho $comp1 . $comp2; - - $doIf = FALSE; - switch ($matches[2]) { - case "==": - $doIf = ($comp1 == $comp2); - break; - case "!=": - $doIf = ($comp1 != $comp2); - break; - case "<": - $doIf = ($comp1 < $comp2); - break; - case ">": - $doIf = ($comp1 > $comp2); - break; + $doIf = false; + + if (trim ($cmdParam) == "::NL_ELSE_FALSE") { + // This is the {else} path of a if construction + if ($ifConditionDidMatch == false) + $doIf = true; // Run the block if + + } else { + + if ( ! preg_match('/([\"\']?.*?[\"\']?)\s*(==|<|>|!=)\s*([\"\']?.*[\"\']?)/i', $cmdParam, $matches)) { + return "!! Invalid command sequence: '$cmdParam' !!"; + } + + //print_r ($matches); + + $comp1 = $this->_getItemValue(trim($matches[1]), $context); + $comp2 = $this->_getItemValue(trim($matches[3]), $context); + + //decho $comp1 . $comp2; + + + switch ($matches[2]) { + case "==": + $doIf = ($comp1 == $comp2); + break; + case "!=": + $doIf = ($comp1 != $comp2); + break; + case "<": + $doIf = ($comp1 < $comp2); + break; + case ">": + $doIf = ($comp1 > $comp2); + break; + } } if ( ! $doIf) return ""; + $ifConditionDidMatch = true; // Skip further else / elseif execution $content = $this->_parseBlock($context, $content, $softFail); $content = $this->_parseValueOfTags($context, $content, $softFail); return $content; } + public function _runIfElse ($context, $content, $softFail=TRUE, &$ifConditionDidMatch) { + if ($ifConditionDidMatch == true) + return ""; + $ifConditionDidMatch = true; // Skip further else / elseif execution + $content = $this->_parseBlock($context, $content, $softFail); + $content = $this->_parseValueOfTags($context, $content, $softFail); + return $content; + } + private function _parseBlock ($context, $block, $softFail=TRUE) { // (?!\{): Lookahead Regex: Don't touch double {{ - $result = preg_replace_callback('/\n?\{(?!=)(([a-z]+)[0-9]+)(.*?)\}(.*?)\n?\{\/\1\}/ism', - function ($matches) use ($context, $softFail) { - $command = $matches[2]; - $cmdParam = $matches[3]; - $content = $matches[4]; + $ifConditionDidMatch = []; // Array with nesting-Levels + $result = preg_replace_callback('/\n?\{(?!=)((?[a-z]+)(?[0-9]+))(?.*?)\}(?.*?)\n?\{\/\1\}/ism', + function ($matches) use ($context, $softFail, &$ifConditionDidMatch) { + $command = $matches["command"]; + $cmdParam = $matches["cmdParam"]; + $content = $matches["content"]; + $nestingLevel = $matches["nestingLevel"]; switch ($command) { case "for": return $this->_runFor($context, $content, $cmdParam, $softFail); case "if": - return $this->_runIf ($context, $content, $cmdParam, $softFail); + $ifConditionDidMatch[$nestingLevel] = false; + return $this->_runIf ($context, $content, $cmdParam, $softFail, $ifConditionDidMatch[$nestingLevel]); + default: return "!! Invalid command: '$command' !!"; @@ -350,7 +389,7 @@ public function apply ($params, $softFail=TRUE) { $text = $this->mTemplateText; $context = $params; - + $text = $this->_replaceElseIf($text); $text = $this->_replaceNestingLevels($text); $text = $this->_parseBlock($context, $text, $softFail); diff --git a/test/templates.phpt b/test/templates.phpt index 1e6a1ab..f34b671 100644 --- a/test/templates.phpt +++ b/test/templates.phpt @@ -17,6 +17,10 @@ use Tester\Assert; \Tester\Environment::setup(); +$in = "{ if xyz}{ if zzz}{=value}{ /if}{else}{/if}"; +$tt = new TextTemplate(); +$out = $tt->_replaceElseIf($in); +Assert::equal("{ if xyz}{ if zzz}{=value}{ /if}{/if}{if ::NL_ELSE_FALSE}{/if}", $out); $in = "{ if xyz}{ if zzz}{=value}{ /if}{/if}"; $tt = new TextTemplate(); diff --git a/test/unit/tpls/07_if_else/out.txt b/test/unit/tpls/07_if_else/out.txt index f8b3cc5..16fad5c 100644 --- a/test/unit/tpls/07_if_else/out.txt +++ b/test/unit/tpls/07_if_else/out.txt @@ -1,5 +1,5 @@ -1: Some Value -2: 1.234 +1: Start 2: Boolean is true 3: Some Line of Code -5: Some other text \ No newline at end of file +5: Some Line of Code +6: Some other text \ No newline at end of file From 05c152306ca317f127df95f046a9f5959f7c06d4 Mon Sep 17 00:00:00 2001 From: matthes Date: Wed, 26 Jul 2017 20:12:32 +0200 Subject: [PATCH 3/5] Added elseif construction (Broken!) Not working! --- src/TextTemplate.php | 91 ++++++++++++++++++----------- test/templates.phpt | 6 ++ test/unit/tpls/07_if_else/_in.txt | 12 ++-- test/unit/tpls/07_if_else/out.txt | 9 ++- test/unit/tpls/08_if_elseif/_in.php | 5 ++ test/unit/tpls/08_if_elseif/_in.txt | 14 +++++ test/unit/tpls/08_if_elseif/out.txt | 4 ++ 7 files changed, 95 insertions(+), 46 deletions(-) create mode 100644 test/unit/tpls/08_if_elseif/_in.php create mode 100644 test/unit/tpls/08_if_elseif/_in.txt create mode 100644 test/unit/tpls/08_if_elseif/out.txt diff --git a/src/TextTemplate.php b/src/TextTemplate.php index d4824d6..1f8856c 100644 --- a/src/TextTemplate.php +++ b/src/TextTemplate.php @@ -98,6 +98,13 @@ function ($matches) use (&$nestingIndex, &$indexCounter, &$li) { }, $lines[$li] ); + $lines[$li] = preg_replace_callback('/\{else\s*if(.*)\}/im', + function ($matches) use (&$nestingIndex, &$indexCounter, &$li) { + print_r ($matches); + return "{/if}{if ::NL_ELSE_FALSE {$matches[1]}}"; + }, + $lines[$li] + ); } return implode ("\n", $lines); @@ -284,39 +291,52 @@ private function _runIf ($context, $content, $cmdParam, $softFail=TRUE, &$ifCond //echo $cmdParam; $doIf = false; - if (trim ($cmdParam) == "::NL_ELSE_FALSE") { + $cmdParam = trim ($cmdParam); + echo "\n+ $cmdParam " . strpos($cmdParam, "::NL_ELSE_FALSE"); + // Handle {else}{elseif} constructions + if ($cmdParam === "::NL_ELSE_FALSE") { + echo "ELSE "; // This is the {else} path of a if construction - if ($ifConditionDidMatch == false) - $doIf = true; // Run the block if - - } else { - - if ( ! preg_match('/([\"\']?.*?[\"\']?)\s*(==|<|>|!=)\s*([\"\']?.*[\"\']?)/i', $cmdParam, $matches)) { - return "!! Invalid command sequence: '$cmdParam' !!"; + if ($ifConditionDidMatch == true) { + echo "BREAK ELSE"; + return ""; // Do not run else block + } + $cmdParam = "TRUE==TRUE"; + } elseif (strpos($cmdParam, "::NL_ELSE_FALSE") === 0) { + echo "ELSEIF "; + // This is a {elseif (condition)} block + if ($ifConditionDidMatch == true) { + echo "BREAK!"; + return ""; // Do not run ifelse block, if block before succeeded } - //print_r ($matches); - - $comp1 = $this->_getItemValue(trim($matches[1]), $context); - $comp2 = $this->_getItemValue(trim($matches[3]), $context); - - //decho $comp1 . $comp2; + $cmdParam = substr($cmdParam, strlen ("::NL_ELSE_FALSE")+1); + } else { + echo "IF "; + // This is the original {if} + $ifConditionDidMatch = false; + } + if ( ! preg_match('/([\"\']?.*?[\"\']?)\s*(==|<|>|!=)\s*([\"\']?.*[\"\']?)/i', $cmdParam, $matches)) { + return "!! Invalid command sequence: '$cmdParam' !!"; + } - switch ($matches[2]) { - case "==": - $doIf = ($comp1 == $comp2); - break; - case "!=": - $doIf = ($comp1 != $comp2); - break; - case "<": - $doIf = ($comp1 < $comp2); - break; - case ">": - $doIf = ($comp1 > $comp2); - break; - } + $comp1 = $this->_getItemValue(trim($matches[1]), $context); + $comp2 = $this->_getItemValue(trim($matches[3]), $context); + + switch ($matches[2]) { + case "==": + $doIf = ($comp1 == $comp2); + break; + case "!=": + $doIf = ($comp1 != $comp2); + break; + case "<": + $doIf = ($comp1 < $comp2); + break; + case ">": + $doIf = ($comp1 > $comp2); + break; } if ( ! $doIf) @@ -339,24 +359,25 @@ public function _runIfElse ($context, $content, $softFail=TRUE, &$ifConditionDid } + private $ifConditionMatch = []; + private function _parseBlock ($context, $block, $softFail=TRUE) { // (?!\{): Lookahead Regex: Don't touch double {{ - $ifConditionDidMatch = []; // Array with nesting-Levels + $result = preg_replace_callback('/\n?\{(?!=)((?[a-z]+)(?[0-9]+))(?.*?)\}(?.*?)\n?\{\/\1\}/ism', - function ($matches) use ($context, $softFail, &$ifConditionDidMatch) { + function ($matches) use ($context, $softFail) { $command = $matches["command"]; $cmdParam = $matches["cmdParam"]; $content = $matches["content"]; $nestingLevel = $matches["nestingLevel"]; - + print_r ($this->ifConditionMatch); + echo "\n> command $nestingLevel: A $command $cmdParam"; switch ($command) { case "for": return $this->_runFor($context, $content, $cmdParam, $softFail); case "if": - $ifConditionDidMatch[$nestingLevel] = false; - return $this->_runIf ($context, $content, $cmdParam, $softFail, $ifConditionDidMatch[$nestingLevel]); - + return $this->_runIf ($context, $content, $cmdParam, $softFail, $this->ifConditionMatch[$nestingLevel]); default: return "!! Invalid command: '$command' !!"; @@ -389,9 +410,9 @@ public function apply ($params, $softFail=TRUE) { $text = $this->mTemplateText; $context = $params; + $text = $this->_replaceElseIf($text); $text = $this->_replaceNestingLevels($text); - $text = $this->_parseBlock($context, $text, $softFail); $result = $this->_parseValueOfTags($context, $text, $softFail); diff --git a/test/templates.phpt b/test/templates.phpt index f34b671..45b710b 100644 --- a/test/templates.phpt +++ b/test/templates.phpt @@ -22,6 +22,12 @@ $tt = new TextTemplate(); $out = $tt->_replaceElseIf($in); Assert::equal("{ if xyz}{ if zzz}{=value}{ /if}{/if}{if ::NL_ELSE_FALSE}{/if}", $out); +$in = "{ if xyz}{ if zzz}{=value}{ /if}{elseif bbb}{/if}"; +$tt = new TextTemplate(); +$out = $tt->_replaceElseIf($in); +Assert::equal("{ if xyz}{ if zzz}{=value}{ /if}{/if}{if ::NL_ELSE_FALSE bbb}{/if}", $out); + + $in = "{ if xyz}{ if zzz}{=value}{ /if}{/if}"; $tt = new TextTemplate(); $out = $tt->_replaceNestingLevels($in); diff --git a/test/unit/tpls/07_if_else/_in.txt b/test/unit/tpls/07_if_else/_in.txt index 4a34bb0..eb4eda7 100644 --- a/test/unit/tpls/07_if_else/_in.txt +++ b/test/unit/tpls/07_if_else/_in.txt @@ -1,12 +1,12 @@ -1: Start +1: IN = 4 {if boolVal == TRUE} -2: Boolean is true +2: IN {else} -3: Some Line of Code +3: OUT {/if} {if boolVal == FALSE} -4: Boolean is true +4: OUT {else} -5: Some Line of Code +5: IN {/if} -6: Some other text \ No newline at end of file +6: IN \ No newline at end of file diff --git a/test/unit/tpls/07_if_else/out.txt b/test/unit/tpls/07_if_else/out.txt index 16fad5c..8a5fb7f 100644 --- a/test/unit/tpls/07_if_else/out.txt +++ b/test/unit/tpls/07_if_else/out.txt @@ -1,5 +1,4 @@ -1: Start -2: Boolean is true -3: Some Line of Code -5: Some Line of Code -6: Some other text \ No newline at end of file +1: IN = 4 +2: IN +5: IN +6: IN \ No newline at end of file diff --git a/test/unit/tpls/08_if_elseif/_in.php b/test/unit/tpls/08_if_elseif/_in.php new file mode 100644 index 0000000..162d97a --- /dev/null +++ b/test/unit/tpls/08_if_elseif/_in.php @@ -0,0 +1,5 @@ + TRUE +]; \ No newline at end of file diff --git a/test/unit/tpls/08_if_elseif/_in.txt b/test/unit/tpls/08_if_elseif/_in.txt new file mode 100644 index 0000000..e14691a --- /dev/null +++ b/test/unit/tpls/08_if_elseif/_in.txt @@ -0,0 +1,14 @@ +1: IN = 4 +{if boolVal == TRUE} +2: IN +{elseif boolVal == TRUE} +3: OUT +{/if} +{if boolVal == FALSE} +4: OUT +{elseif boolVal == TRUE} +5: IN +{else} +6: OUT +{/if} +7: IN \ No newline at end of file diff --git a/test/unit/tpls/08_if_elseif/out.txt b/test/unit/tpls/08_if_elseif/out.txt new file mode 100644 index 0000000..737dc7c --- /dev/null +++ b/test/unit/tpls/08_if_elseif/out.txt @@ -0,0 +1,4 @@ +1: IN = 4 +2: IN +5: IN +7: IN \ No newline at end of file From 5f0f656bfbf957a85c31773aef086b202d3a61d9 Mon Sep 17 00:00:00 2001 From: matthes Date: Wed, 26 Jul 2017 20:34:13 +0200 Subject: [PATCH 4/5] Added elseif construction (Working!) --- src/TextTemplate.php | 24 ++++++++++++++++++------ test/templates.phpt | 18 ++++++++++-------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/TextTemplate.php b/src/TextTemplate.php index 1f8856c..2bd08ba 100644 --- a/src/TextTemplate.php +++ b/src/TextTemplate.php @@ -92,16 +92,16 @@ public function addFilter ($filterName, callable $filterFn) { public function _replaceElseIf ($input) { $lines = explode("\n", $input); for ($li=0; $li < count ($lines); $li++) { - $lines[$li] = preg_replace_callback('/\{else\}/im', + $lines[$li] = preg_replace_callback('/\{else(?[0-9]+)\}/im', function ($matches) use (&$nestingIndex, &$indexCounter, &$li) { - return "{/if}{if ::NL_ELSE_FALSE}"; + return "{/if{$matches["nestingLevel"]}}{if{$matches["nestingLevel"]} ::NL_ELSE_FALSE}"; }, $lines[$li] ); - $lines[$li] = preg_replace_callback('/\{else\s*if(.*)\}/im', + $lines[$li] = preg_replace_callback('/\{elseif(?[0-9]+)(?.*)\}/im', function ($matches) use (&$nestingIndex, &$indexCounter, &$li) { - print_r ($matches); - return "{/if}{if ::NL_ELSE_FALSE {$matches[1]}}"; + + return "{/if{$matches["nestingLevel"]}}{if{$matches["nestingLevel"]} ::NL_ELSE_FALSE {$matches["params"]}}"; }, $lines[$li] ); @@ -142,6 +142,16 @@ function ($matches) use (&$nestingIndex, &$indexCounter, &$li) { $slash = $matches[1]; $tag = $matches[2]; $rest = $matches[3]; + if ($tag == "else" || $tag == "elseif"){ + + if ( ! isset ($nestingIndex["if"])) + throw new \Exception("Line {$li}: 'if' Opening tag not found for else/elseif tag: '{$matches[0]}'"); + if (count ($nestingIndex["if"]) == 0) + throw new \Exception("Line {$li}: Nesting level does not match for closing tag: '{$matches[0]}'"); + $curIndex = $nestingIndex["if"][count ($nestingIndex["if"])-1]; + $out = "{" . $tag . $curIndex[0] . rtrim($rest) . "}"; + return $out; + } if ($slash == "") { if ( ! isset ($nestingIndex[$tag])) $nestingIndex[$tag] = []; @@ -411,8 +421,10 @@ public function apply ($params, $softFail=TRUE) { $context = $params; - $text = $this->_replaceElseIf($text); + $text = $this->_replaceNestingLevels($text); + $text = $this->_replaceElseIf($text); + $text = $this->_parseBlock($context, $text, $softFail); $result = $this->_parseValueOfTags($context, $text, $softFail); diff --git a/test/templates.phpt b/test/templates.phpt index 45b710b..d2263b6 100644 --- a/test/templates.phpt +++ b/test/templates.phpt @@ -16,22 +16,24 @@ use Tester\Assert; \Tester\Environment::setup(); - $in = "{ if xyz}{ if zzz}{=value}{ /if}{else}{/if}"; $tt = new TextTemplate(); +$out = $tt->_replaceNestingLevels($in); +Assert::equal("{if0 xyz}{if1 zzz}{=value}{/if1}{else0}{/if0}", $out); + + +$in = "{ if0 xyz}{ if1 zzz}{=value}{ /if1}{else0}{/if0}"; +$tt = new TextTemplate(); $out = $tt->_replaceElseIf($in); -Assert::equal("{ if xyz}{ if zzz}{=value}{ /if}{/if}{if ::NL_ELSE_FALSE}{/if}", $out); +Assert::equal("{ if0 xyz}{ if1 zzz}{=value}{ /if1}{/if0}{if0 ::NL_ELSE_FALSE}{/if0}", $out); -$in = "{ if xyz}{ if zzz}{=value}{ /if}{elseif bbb}{/if}"; +$in = "{ if0 xyz}{ if1 zzz}{=value}{ /if1}{elseif0 bbb}{/if0}"; $tt = new TextTemplate(); $out = $tt->_replaceElseIf($in); -Assert::equal("{ if xyz}{ if zzz}{=value}{ /if}{/if}{if ::NL_ELSE_FALSE bbb}{/if}", $out); +Assert::equal("{ if0 xyz}{ if1 zzz}{=value}{ /if1}{/if0}{if0 ::NL_ELSE_FALSE bbb}{/if0}", $out); + -$in = "{ if xyz}{ if zzz}{=value}{ /if}{/if}"; -$tt = new TextTemplate(); -$out = $tt->_replaceNestingLevels($in); -Assert::equal("{if0 xyz}{if1 zzz}{=value}{/if1}{/if0}", $out); From 73ce4b332509c4dce6c6c940a5e60692675d263e Mon Sep 17 00:00:00 2001 From: matthes Date: Wed, 26 Jul 2017 20:41:58 +0200 Subject: [PATCH 5/5] Added elseif construction (Working!) --- README.md | 14 ++++++++++++++ src/TextTemplate.php | 11 ++--------- test/unit/tpls/08_if_elseif_complex/_in.php | 6 ++++++ test/unit/tpls/08_if_elseif_complex/_in.txt | 16 ++++++++++++++++ test/unit/tpls/08_if_elseif_complex/out.txt | 4 ++++ 5 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 test/unit/tpls/08_if_elseif_complex/_in.php create mode 100644 test/unit/tpls/08_if_elseif_complex/_in.txt create mode 100644 test/unit/tpls/08_if_elseif_complex/out.txt diff --git a/README.md b/README.md index 644f186..76dca51 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,8 @@ $tplStr = <<ifConditionMatch); - echo "\n> command $nestingLevel: A $command $cmdParam"; + switch ($command) { case "for": return $this->_runFor($context, $content, $cmdParam, $softFail); @@ -421,7 +415,6 @@ public function apply ($params, $softFail=TRUE) { $context = $params; - $text = $this->_replaceNestingLevels($text); $text = $this->_replaceElseIf($text); diff --git a/test/unit/tpls/08_if_elseif_complex/_in.php b/test/unit/tpls/08_if_elseif_complex/_in.php new file mode 100644 index 0000000..83aa529 --- /dev/null +++ b/test/unit/tpls/08_if_elseif_complex/_in.php @@ -0,0 +1,6 @@ + TRUE, + "t2" => TRUE +]; \ No newline at end of file diff --git a/test/unit/tpls/08_if_elseif_complex/_in.txt b/test/unit/tpls/08_if_elseif_complex/_in.txt new file mode 100644 index 0000000..acae8f6 --- /dev/null +++ b/test/unit/tpls/08_if_elseif_complex/_in.txt @@ -0,0 +1,16 @@ +1: IN = 4 +{if t1 == TRUE} +2: IN +{if t2 == FALSE} +3: OUT +{elseif t2 == TRUE} +4: IN +{else} +5: OUT +{/if} +{elseif t1 == TRUE} +6: OUT +{else} +7: OUT +{/if} +8: IN \ No newline at end of file diff --git a/test/unit/tpls/08_if_elseif_complex/out.txt b/test/unit/tpls/08_if_elseif_complex/out.txt new file mode 100644 index 0000000..24d0389 --- /dev/null +++ b/test/unit/tpls/08_if_elseif_complex/out.txt @@ -0,0 +1,4 @@ +1: IN = 4 +2: IN +4: IN +8: IN \ No newline at end of file