Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandr-ru committed Aug 9, 2016
1 parent 9bfa9de commit 5e36906
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
7 changes: 6 additions & 1 deletion tests/multifilter.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
raw:
<div>{{VAR|raw}}</div>
wrongfilter2:
<div>{{VAR|html|wrongfilter|}}</div>
<div>{{VAR|html|wrongfilter|}}</div>

inherit filter:
<!-- BEGIN block1 -->
<div>{{VAR|html2}}</div>
<!-- END block1 -->
</body>
</html>
22 changes: 19 additions & 3 deletions tests/multifilter.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
<?php
//header("content-type: text/plain");
require('../TemplateObject.php');
$to = new TemplateObject();
$to->loadTemplate('multifilter.html');
//$to = new TemplateObject();
//$to->loadTemplate('multifilter.html');
$to = TemplateObject::loadTemplate('multifilter.html');
$to->setVariable('TITLE', "Multiple filter test");

$string = "This a string with \"quotes\" and several lines\nsecond line\nthitd line";
$to->setVariable('VAR', $string);

$to->addFilter('wrongfilter', function($a){ return 'wrong! '.$a; });
$to->removeFilter('raw');
$to->addFilter('html', 'htmlentities', TRUE);
$to->addFilter('html', 'html_cb', TRUE);
$to->addFilter('html2', 'html2_cb');

for($i=1; $i<=3; $i++) {
$b = $to->setBlock('block1');
$b->setVariable('VAR', $string);
}

$to->showOutput();

function html_cb($a)
{
return '<font color=red>' . htmlentities($a) . '</font>';
}

function html2_cb($a)
{
return '<font color=green>' . htmlentities($a) . '</font>';
}
?>

0 comments on commit 5e36906

Please sign in to comment.