phpcheck.jspittemplate.php Total: 90 Tests, 0 Errors, ↻all
PHPCheck V1.66, OS: Linux, Machine: el8_10.x86_64, PHP-Version: 8.2.28 (64 Bit), Time: 6.872 ms (AVG: 0.076 ms), Memory: 2.0M (512M)

Cycle:1

CommentLineCodeResultTest
show POST 22 $result $_POST;
$t->check($resulttrue); 
[0.001 ms]
array (
)
Ok
include class JspitTemplate 26 require __DIR__.'/../class/'.strtr(JspitTemplate::class,['\\' => '/']).'.php';
$t->checkEqual(class_exists(JspitTemplate::class) , true); 
[0.920 ms]
true
Ok
check versions info 31 $info $t->getClassVersion(new JspitTemplate);
$t->check($info, !empty($info) AND $info >= 1.5); 
[0.122 ms]
1.5
Ok
create object from string 36 $template '<h3>{{welcome}}</h3>';
$tpl JspitTemplate::createFromString($template);
$t->check($tpl$tpl instanceof JspitTemplate); 
[0.098 ms]
\JspitTemplate::__set_state(array(
   'tpl' => '<h3>{{welcome}}</h3>',
   'assign' => 
  array (
  ),
   'userFct' => 
  array (
  ),
))
Ok
create object from string + save 41 $fileName 'phpcheck.tpl';
$template '<h3>{{welcome2}}</h3>';
$tpl JspitTemplate::createFromString($template)
  ->
save($fileName)
;
$result file_get_contents($fileName);
$t->checkEqual($result$template); 
[1.631 ms]

{{welcome2}}

Ok
create object from file 50 $fileName 'phpcheck.tpl';
$result JspitTemplate::create($fileName)
  ->
getTemplate()
;
$t->checkEqual($result$template); 
[0.237 ms]

{{welcome2}}

Ok
render from file 57 $tpl = new JspitTemplate;
$result $tpl->render('phpcheck.tpl',['welcome2' => 'Hello World']);
$expected '<h3>Hello World</h3>';
$t->checkEqual($result$expected); 
[0.384 ms]

Hello World

Ok
load file and render 63 $tpl = new JspitTemplate;
$result $tpl
  
->loadFile('phpcheck.tpl')
  ->
render(['welcome2' => 'Hello World2'])
;
$expected '<h3>Hello World2</h3>';
unlink($fileName);
$t->checkEqual($result$expected); 
[1.063 ms]

Hello World2

Ok
set global template path 73 $result JspitTemplate::setTemplatePath(__DIR__);
$expected str_replace('\\','/',__DIR__."/");
$t->checkEqual($result$expected); 
[0.007 ms]
/mnt/web313/c0/70/5508370/htdocs/pju24/check/
Ok
render from string 79 $result JspitTemplate::renderFromString(
  
'<h1>{{welcome}}</h1>',
  [
'welcome' => 'Hello JspitTemplate']
);
$expected '<h1>Hello JspitTemplate</h1>';
$t->checkEqual($result$expected); 
[0.097 ms]

Hello JspitTemplate

Ok
show html without assign 89 // show results as HTML 
$template '<h3>{{welcome}}</h3>';
$tpl JspitTemplate::createFromString($template);
$html $tpl->getHTML();
$t->checkHTML($html,'<h3>{{welcome}}</h3>'); 
[0.010 ms]

{{welcome}}

Ok
show html without assign and default value 96 $template '<h3>{{welcome ?? "default"}}</h3>';
$tpl JspitTemplate::createFromString($template);
$html $tpl->getHTML();
$t->checkHTML($html,'<h3>default</h3>'); 
[0.017 ms]

default

Ok
show html without assign and default value 102 $template "<h3>{{welcome|date('d.m.Y') ?? '01.01.2020'}}</h3>";
$tpl JspitTemplate::createFromString($template);
$html $tpl->getHTML();
$t->checkHTML($html,'<h3>01.01.2020</h3>'); 
[0.011 ms]

01.01.2020

Ok
show html without assign and empty default value 108 $templateEmptyDefault "{{name ?? ''}}";
$tpl JspitTemplate::createFromString($templateEmptyDefault);
$html $tpl->getHTML();
$t->checkHTML($html,''); 
[0.009 ms]
Ok
#assignOnce : set a single template variable 114 $html JspitTemplate::createFromString($template)
  ->
assignOnce(["welcome" => "Happy New Year"])
  ->
getHTML();
$t->checkHTML($html,'<h3>Happy New Year</h3>'); 
[0.160 ms]

Happy New Year

Ok
assignOnce array 120 $set = ['foo' => 'bar''welcome' => 'AssignOnce Array Element'];
$html JspitTemplate::createFromString($template)
  ->
assignOnce($set)
  ->
getHTML();
$t->checkHTML($html,'<h3>AssignOnce Array Element</h3>'); 
[0.081 ms]

AssignOnce Array Element

Ok
assignOnce numerical array 127 $temp 'Name: {{par.0}} Mail: {{par.1}}';
$html JspitTemplate::createFromString($temp)
  ->
assignOnce(['par' => ["Name1""Mail1" ]])
  ->
getHtml()
;
$t->checkHTML($html,'Name: Name1 Mail: Mail1'); 
[0.066 ms]
Name: Name1 Mail: Mail1
Ok
assignOnce NULL : show default 135 $template "<h3>{{welcome ?? 'show if assign null'}}</h3>";
$set = ['foo' => 'bar''welcome' => NULL];
$html JspitTemplate::createFromString($template)
  ->
assignOnce($set)
  ->
getHTML();
$t->checkHTML($html,'<h3>show if assign null</h3>'); 
[0.023 ms]

show if assign null

Ok
assignOnce invalid key 143 $template 'abc{{ foo ?? "def val" }}123';
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['fo'=> 'bar'])
  ->
getHTML();
$t->checkHTML($html,'abcdef val123'); 
[0.080 ms]
abcdef val123
Ok
assignOnce object placeholder 150 $template 'abc{{ foo.bar }}def';
$html JspitTemplate::createFromString($template)
  ->
assignOnce([
    
'foo' => ['bar' => 123]
  ])
  ->
getHTML();
$t->checkHTML($html,'abc123def'); 
[0.018 ms]
abc123def
Ok
assignOnce object to object placeholder 159 $template 'abc {{ foo.val }} {{ foo.unit }}';
class 
testobj{public $val 34; public $unit 'grd';}
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['foo' => new testobj])
  ->
getHTML();
$t->checkHTML($html,'abc 34 grd'); 
[0.025 ms]
abc 34 grd
Ok
assignOnce template with assignOnce to template 168 $subTemplate 's{{ bar ?? "default" }}s';
$sTpl JspitTemplate::createFromString($subTemplate)
  ->
assignOnce(['bar' => 'xx'])
;
$template 'abc{{ foo }}123';  
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['foo' => $sTpl])
  ->
getHTML()
;
$t->checkHTML($html,'abcsxxs123'); 
[0.106 ms]
abcsxxs123
Ok
assignOnce template to template before assignOnce 180 $subTemplate 's{{ bar ?? "default" }}s';
$sTpl JspitTemplate::createFromString($subTemplate);
$template 'abc{{ stpl|html }}123';
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['stpl'=> $sTpl])
  ->
assignOnce(['bar' => 'xx'])
  ->
getHTML();
$t->checkHTML($html,'abcsxxs123'); 
[0.063 ms]
abcsxxs123
Ok
assignOnce template with default to template 190 $subTemplate 's{{ bar ?? "default" }}s';
$sTpl JspitTemplate::createFromString($subTemplate);
$template 'abc{{ stpl }}123';
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['stpl' => $sTpl])
  ->
getHTML();
$t->checkHTML($html,'abcsdefaults123'); 
[0.017 ms]
abcsdefaults123
Ok
#escape to html is standard 202 //From here show results as HTML code
$template 'abc{{ foo }}def';
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['foo' => '3 > 2'])
  ->
getHTML();
$t->checkHTML($html,'3 &gt; 2'); 
[0.015 ms]
'abc3 > 2def'
Ok
escape defaults are fix 210 $template '{{ foo ?? "<b>"}}';
$html JspitTemplate::createFromString($template)
  ->
getHTML();
$t->checkHTML($html,'&lt;b&gt;'); 
[0.011 ms]
'<b>'
Ok
assignOnce html code 220 $template 'abc{{ foo|html }}def';
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['foo' => '<b>bold</b>'])
  ->
getHTML();
$t->checkHTML($html,'abc<b>bold</b>def'); 
[0.017 ms]
'abc<b>bold</b>def'
Ok
assignOnce html code with raw 227 $template 'abc{{ foo|raw }}def';
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['foo'=> '<b>raw</b>'])
  ->
getHTML();
$t->checkHTML($html,'abc<b>raw</b>def'); 
[0.016 ms]
'abc<b>raw</b>def'
Ok
assignOnce single parameter with filter url 235 $template '<a href="?par={{ par|url }}">Click</a>';
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['par' => '1 2 3'])
  ->
getHTML();
$t->checkEqual($html,'<a href="?par=1%202%203">Click</a>'); 
[0.019 ms]
'<a href="?par=1%202%203">Click</a>'
Ok
assignOnce par array with filter url 242 $template '<a href="?{{ par|url }}">Click</a>';
$html JspitTemplate::createFromString($template)
  ->
assignOnce([
    
'par' => ['p1' => '1''p2' => 2], 
    ])
  ->
getHTML();
$t->checkEqual($html,'<a href="?p1=1&amp;p2=2">Click</a>'); 
[0.018 ms]
'<a href="?p1=1&p2=2">Click</a>'
Ok
assignOnce par array with filter url + raw 251 $template '<a href="?{{ par|url|raw }}">Click</a>';
$html JspitTemplate::createFromString($template)
  ->
assignOnce([
    
'par' => ['p1' => '1''p2' => 2], 
    ])
  ->
getHTML();
$t->checkEqual($html,'<a href="?p1=1&p2=2">Click</a>'); 
[0.017 ms]
'<a href="?p1=1&p2=2">Click</a>'
Ok
assignOnce invalid key + html 260 $template 'abc{{ foo|html ?? "def val" }}123';
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['fo' => 'bar'])
  ->
getHTML();
$t->checkHTML($html,'abcdef val123'); 
[0.011 ms]
'abcdef val123'
Ok
assignOnce integer, use format 268 $template 'intval={{intval|format("%03d")}}';
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['intval' => 9])
  ->
getHTML();
$t->checkHTML($html,'intval=009'); 
[0.066 ms]
'intval=009'
Ok
assignOnce float, use format 275 $template 'floatval={{floatval|format("%.2f")}}';
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['floatval' => 11.2384])
  ->
getHTML();
$t->checkHTML($html,'floatval=11.24'); 
[0.085 ms]
'floatval=11.24'
Ok
assignOnce array of int, use format 282 $template 'intvals={{intvals|format("%03d - %03d")}}';
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['intvals' => [1,9]])
  ->
getHTML();
$t->checkHTML($html,'intvals=001 - 009'); 
[0.067 ms]
'intvals=001 - 009'
Ok
assignOnce DateTime, use date 289 $template 'Date:{{date|date(" d.m.Y")}}';
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['date' => date_create('2020-10-28')])
  ->
getHTML();
$t->checkHTML($html,'Date: 28.10.2020'); 
[0.088 ms]
'Date: 28.10.2020'
Ok
assignOnce Timestamp, use date 296 $template 'Date:{{timestamp|date(" d.m.Y H:i")}}';
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['timestamp' => strtotime('2020-10-28 14:45')])
  ->
getHTML();
$t->checkHTML($html,'Date: 28.10.2020 14:45'); 
[0.066 ms]
'Date: 28.10.2020 14:45'
Ok
assignOnce Datestring, use date 303 $template 'Date:{{date|date(" d.m.Y H:i")}}';
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['date' => '2021-01-20'])
  ->
getHTML();
$t->checkHTML($html,'Date: 20.01.2021 00:00'); 
[0.022 ms]
'Date: 20.01.2021 00:00'
Ok
assignOnce relative Datestring, use date 310 $template 'Date:{{date|date("l, d.m.Y")}}';
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['date' => 'today'])
  ->
getHTML();
$expected 'Date:'.date_create('today')->format("l, d.m.Y");
$t->checkHTML($html,$expected); 
[0.019 ms]
'Date:Friday, 09.05.2025'
Ok
Filter "selected" post not set with default value 318 $template "{{post.sel|selected('p1') ?? 'selected'}}";
$html JspitTemplate::createFromString($template)
  ->
getHTML()
;
$t->checkEqual($html,'selected'); 
[0.008 ms]
'selected'
Ok
Filter "selected" post not set with default value space 325 $template "{{post.sel|selected('p2') ?? ' '}}";
$html JspitTemplate::createFromString($template)
  ->
getHTML()
;
$t->checkEqual($html,' '); 
[0.004 ms]
' '
Ok
Filter "selected p1" with post p2 332 $template "{{post.sel|selected('p1') ?? 'selected'}}";
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['post' => ['sel' => 'p2']])
  ->
getHTML()
;
$t->checkEqual($html,''); 
[0.047 ms]
''
Ok
Filter "selected p2" with post p2 340 $template "{{post.sel|selected('p2') ?? 'selected'}}";
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['post' => ['sel' => 'p2']])
  ->
getHTML()
;
$t->checkEqual($html,'selected'); 
[0.011 ms]
'selected'
Ok
working select example 349 $template = <<<EOF
<label>Cars:
<select name="selcar" size="1">
  <option value="audi" {{post.selcar|selected("audi") ?? "" }}>Audi</option>
  <option value="bmw" {{post.selcar|selected("bmw") ?? "selected" }}>BMW</option>
</select>
</label>
EOF;
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['post' => $_POST])
  ->
getHTML()
;
$mustContain 'select,name,selcar,Audi,BMW';
$t->checkHTML($html,$mustContain); 
[0.019 ms]
Ok
Filter checked 366 $template "{{post.chk|checked ?? ''}}";
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['post' => ['chk' => 'on']])
  ->
getHTML()
;
$t->checkHTML($html,'checked'); 
[0.014 ms]
'checked'
Ok
Filter checked without key chk 374 $template "{{post.chk|checked ?? ''}}";
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['post' => ['chkOther' => '1']])
  ->
getHTML()
;
$t->checkHTML($html,''); 
[0.012 ms]
''
Ok
Filter checked with assign NULL 382 $template "{{post.chk|checked ?? ''}}";
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['post' => ['chk' => NULL]])
  ->
getHTML()
;
$t->checkHTML($html,''); 
[0.010 ms]
''
Ok
Filter checked('1') 390 $template "{{post.chk|checked('1') ?? ''}}";
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['post' => ['chk' => '1']])
  ->
getHTML()
;
$t->checkHTML($html,'checked'); 
[0.011 ms]
'checked'
Ok
Filter checked('1') without assign 398 $template "{{post.chk|checked('1') ?? ''}}";
$html JspitTemplate::createFromString($template)
  
//->assignOnce(['post' => ['chk' => '1']])
  
->getHTML()
;
$t->checkHTML($html,''); 
[0.004 ms]
''
Ok
working example checkbox and radio 407 $template = <<<EOF
<!-- checkbox 1 not selected on first call -->
<input type="hidden" name="chk1" value="0"> 
<input type="checkbox" name="chk1" value="1" {{post.chk1|checked('1') ?? ' '}}>

<!-- checkbox 2 selected on first call -->
<input type="hidden" name="chk2" value="0"> 
<input type="checkbox" name="chk2" value="1" {{post.chk2|checked('1') ?? 'checked'}}>

<!-- value 1 selected on first call -->
<input name="radio" type="radio" value="1"{{post.radio|checked('1') ?? 'checked'}}>Radio 1
<input name="radio" type="radio" value="2" {{post.radio|checked('2') ?? ' '}}>Radio 2
EOF;
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['post' => $_POST])
  ->
getHTML()
;
$mustContain 'checkbox,name';
$t->checkHTML($html,$mustContain); 
[0.033 ms]
Radio 1 Radio 2
Ok
working example input 428 $template = <<<EOF
<!-- simple text input -->
<input type="text" name="inputtext" value="{{post.inputtext ?? ' '}}">

<br><br>
<input name="inputdate" type="date" value="{{inputdate}}">

<br><br>
<button type="submit" value="Submit">Submit</button>

EOF;
$html JspitTemplate::createFromString($template)
  ->
assignOnce([
      
'post' => $_POST,
      
'inputdate' => $_POST['inputdate'] ?? date('Y-m-d'),
    ])
  ->
getHTML()
;
$mustContain 'input,name';
$t->checkHTML($html,$mustContain); 
[0.081 ms]




Ok
Filter blank 451 $template "{{post.submit|blank ?? 'New Form'}}";
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['post' => []])
  ->
getHTML()
;
$t->checkHTML($html,'New Form'); 
[0.013 ms]
'New Form'
Ok
Filter blank after submit 459 $template "{{post.submit|blank ?? 'New Form'}}";
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['post' => ['submit' => 'Sent']])
  ->
getHTML()
;
$t->checkHTML($html,''); 
[0.013 ms]
''
Ok
Filter set 467 $template "{{post.submit|set('Form Sent') ?? 'New Form'}}";
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['post' => []])
  ->
getHTML()
;
$t->checkHTML($html,'New Form'); 
[0.014 ms]
'New Form'
Ok
Filter set sumit + value 475 $template "{{post.submit|set('Form Sent') ?? 'New Form'}}";
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['post' => ['submit' => 'Sent']])
  ->
getHTML()
;
$t->checkHTML($html,'Form Sent'); 
[0.015 ms]
'Form Sent'
Ok
Filter set sumit + empty string 483 $template "{{post.submit|set('Form Sent') ?? 'New Form'}}";
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['post' => ['submit' => '']])
  ->
getHTML()
;
$t->checkHTML($html,''); 
[0.011 ms]
''
Ok
Filter case 1 => 'One' 492 $template '{{switch|case("#Null#One#Two#") ?? "default"}}';
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['switch' => 1])
  ->
getHTML()
;
$t->checkEqual($html,'One'); 
[0.048 ms]
'One'
Ok
Filter case 4 is not in the list => '' 500 $template '{{switch|case("#Null#Eins#Zwo#") ?? "default"}}';
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['switch' => 4])
  ->
getHTML()
;
$t->checkEqual($html,''); 
[0.015 ms]
''
Ok
Filter case false is the same as 0 => 'Null' 508 $template '{{switch|case("#Null#Eins#Zwo#") ?? "default"}}';
$html JspitTemplate::createFromString($template)
  ->
assignOnce(['switch' => false])
  ->
getHTML()
;
$t->checkEqual($html,'Null'); 
[0.012 ms]
'Null'
Ok
Filter abs numeric 517 $template '{{number|abs}}';
$html JspitTemplate::createFromString($template)
  ->
render(['number' => -45.6])
;
$t->checkEqual($html,'45.6'); 
[0.042 ms]
'45.6'
Ok
Filter abs string 524 $template '{{number|abs}}';
$html JspitTemplate::createFromString($template)
  ->
render(['number' => '-abc'])
;
$t->checkEqual($html,'-abc'); 
[0.009 ms]
'-abc'
Ok
Filter sign < 0 532 $template '{{number|sign("~<0~=0~>0~")}}';
$html JspitTemplate::createFromString($template)
  ->
render(['number' => -0.2])
;
$t->checkEqual($html,'&lt;0'); 
[0.010 ms]
'<0'
Ok
Filter sign == 0 539 $template '{{number|sign("~<0~=0~>0~")}}';
$html JspitTemplate::createFromString($template)
  ->
render(['number' => 0])
;
$t->checkEqual($html,'=0'); 
[0.009 ms]
'=0'
Ok
Filter sign > 0 546 $template '{{number|sign("~<0~=0~>0~")}}';
$html JspitTemplate::createFromString($template)
  ->
render(['number' => +0.2])
;
$t->checkEqual($html,'&gt;0'); 
[0.011 ms]
'>0'
Ok
Filter each unordered HTML List 555 $template = <<<EOF
<ul>
{{htmlList|each("<li>#val#</li>")|raw}}
</ul>
EOF;
$html JspitTemplate::createFromString($template)
  ->
render(['htmlList' => ['Coffee','Tea','Milk']])
;
$t->checkHtml($html,'ul,li,Coffee,Tea,Milk'); 
[0.057 ms]
  • Coffee
  • Tea
  • Milk
Ok
Filter each for datalist 566 $template = <<<EOF
<label for="myBrowser">Enter a browser name:</label>
<input list="browsers" id="myBrowser" name="myBrowser" value="{{post.myBrowser ?? ' '}}"/>
<datalist id="browsers">
  {{list|each('<option value="#val#">')|raw}}
</datalist>
EOF;
$html JspitTemplate::createFromString($template)
  ->
render([
    
'list' => ['Chrome','Firefox','Edge','Safari'],
    
'post' => $_POST,
]);
$t->checkContains($html,'option,Chrome,Firefox,Edge,Safari'); 
[0.080 ms]
Ok
Filter each for select 581 $template = <<<EOF
<select name="vehicle" id="vehicle" size="1">
  {{select|each('<option value="#key#">#val#</option>')|raw}}
</select>
EOF;
$html JspitTemplate::createFromString($template)
  ->
render(['select' => ['Bus','Train','Car']])
;
$t->checkHtml($html,'select,option,Bus,Car'); 
[0.063 ms]
Ok
user function (static) without parameter for filter 595 JspitTemplate::addStaticUserFunction('trim','trim');
$temp 'A{{foo|trim}}B';
$html JspitTemplate::createFromString($temp)
  ->
assignOnce(['foo' => " xy "])
  ->
getHTML()
;
$t->checkEqual($html,'AxyB'); 
[0.021 ms]
'AxyB'
Ok
user function (static) without parameter for filter 604 $temp 'A{{foo|trim()}}B';
$html JspitTemplate::createFromString($temp)
  ->
assignOnce(['foo' => " xy "])
  ->
getHTML()
;
$t->checkEqual($html,'AxyB'); 
[0.014 ms]
'AxyB'
Ok
user function (static) with 1 parameter for filter 612 $temp '|{{foo|trim(" x")}}|';
$html JspitTemplate::createFromString($temp)
  ->
assignOnce(['foo' => " xy "])
  ->
getHTML()
;
$t->checkEqual($html,'|y|'); 
[0.010 ms]
'|y|'
Ok
user function with 1 parameter for filter 620 $temp '|{{foo|ucfirst}}|';
$html JspitTemplate::createFromString($temp)
  ->
addUserFunction('ucfirst','ucfirst')
  ->
assignOnce(['foo' => "xy"])
  ->
getHTML()
;
$t->checkEqual($html,'|Xy|'); 
[0.011 ms]
'|Xy|'
Ok
user function with anonymous function 629 $template '{{val|myfct("Date %04d-%02d-%02d") ?? "default"}}';
$html JspitTemplate::createFromString($template)
  ->
addUserFunction('myfct',function($val,$par){
    return 
sprintf($par$val[0],$val[1],$val[2]);
   })
  ->
assignOnce(['val' => [2021,7,29]])
  ->
getHTML()
;
$t->checkEqual($html,"Date 2021-07-29"); 
[0.060 ms]
'Date 2021-07-29'
Ok
2 assignOnce with same placeholder 642 $temp 'A{{foo}}B';
$html JspitTemplate::createFromString($temp)
  ->
assignOnce(['foo' => "first"])
  ->
assignOnce(['foo' => "second"])
  ->
getHTML()
;
$t->checkEqual($html,'AfirstB'); 
[0.012 ms]
'AfirstB'
Ok
2 assign with same placeholder 651 $temp 'A{{foo}}B';
$html JspitTemplate::createFromString($temp)
  ->
assign(['foo' => "first"])
  ->
assign(['foo' => "second"])
  ->
getHTML()
;
$t->checkEqual($html,'AsecondB'); 
[0.010 ms]
'AsecondB'
Ok
assign and delete the foo placeholder 660 $temp '{{foo ?? "DefaultFoo"}} and {{bar ?? "default Bar"}}';
$html JspitTemplate::createFromString($temp)
  ->
assign(['foo' => "first",'bar' => 'second'])
  ->
assign(['foo' => NULL])  //delete foo
  
->getHTML()
;
$t->checkEqual($html,"DefaultFoo and second"); 
[0.020 ms]
'DefaultFoo and second'
Ok
assign and delete all placeholders 669 $temp '{{foo ?? "DefaultFoo"}} and {{bar ?? "default Bar"}}';
$html JspitTemplate::createFromString($temp)
  ->
assign(['foo' => "first",'bar' => 'second'])
  ->
assign(NULL)  //delete all
  
->getHTML()
;
$t->checkEqual($html,"DefaultFoo and default Bar"); 
[0.008 ms]
'DefaultFoo and default Bar'
Ok
assign and assignOnce with same placeholder 679 $temp 'A{{foo}}B';
$html JspitTemplate::createFromString($temp)
  ->
assign(['foo' => "first"])
  ->
assignOnce(['foo' => "once!"])
  ->
assign(['foo' => "second"])
  ->
getHTML()
;
$t->checkEqual($html,'Aonce!B'); 
[0.009 ms]
'Aonce!B'
Ok
assign and arrays with same placeholder 689 $temp 'Name:{{p.name}} Mail:{{p.mail}}';
$tpl JspitTemplate::createFromString($temp)
  ->
assign([
    
'p' => ["name" => "?""mail" => "?"
  ]);

$html $tpl ->assign([
    
'p' => ["name" => "Hubert"
  ])
  ->
getHTML()
;
$t->checkEqual($html,'Name:Hubert Mail:?'); 
[0.040 ms]
'Name:Hubert Mail:?'
Ok
assign bevore load template 703 $tpl = new JspitTemplate;
$tpl->assign(['par' => ["Name1""Mail1" ]]);

$temp 'Name:{{par.0}} Mail:{{par.1}}';
$html $tpl
  
->loadString($temp)
  ->
getHtml()
;
$t->checkEqual($html,'Name:Name1 Mail:Mail1'); 
[0.015 ms]
'Name:Name1 Mail:Mail1'
Ok
assign template without assign for subtemplate 714 $tempName 'Name:{{name ?? "defName"}}';
$tplName JspitTemplate::createFromString($tempName);

$tempMain 'Bla Bla {{content ?? "defContent"}}';
$tplMain JspitTemplate::createFromString($tempMain)
  ->
assign([
      
"content" => $tplName,
      
//"name" => "Harry"
  
])
  ->
getHtml()
;
$t->checkEqual($tplMain,'Bla Bla Name:defName'); 
[0.037 ms]
'Bla Bla Name:defName'
Ok
assign template with assign for subtemplate 728 $tempName 'Name:{{name ?? "defName"}}';
$tplName JspitTemplate::createFromString($tempName);

$tempMain 'Bla Bla {{content ?? "defContent"}}';
$tplMain JspitTemplate::createFromString($tempMain)
  ->
assign([
      
"content" => $tplName,
      
"name" => "Harry"
  
])
  ->
getHtml()
;
$t->checkEqual($tplMain,'Bla Bla Name:Harry'); 
[0.048 ms]
'Bla Bla Name:Harry'
Ok
assign placeholder subtemplate after assign subtemplate to main 742 $tempName 'Name:{{name ?? "defName"}}';
$tplName JspitTemplate::createFromString($tempName);

$tempMain 'Bla Bla {{content}}';
//assign subtemplate 
$tplMain JspitTemplate::createFromString($tempMain)
  ->
assign(["content" => $tplName]);
//assign name for subtemplate
$tplName->assign(['name' => 'Harry']);

$html $tplMain->getHtml();
$t->checkEqual($html,'Bla Bla Name:Harry'); 
[0.017 ms]
'Bla Bla Name:Harry'
Ok
Nesting 3 templates 756 $temp1 'From Template1 {{content}}';
$tpl1 JspitTemplate::createFromString($temp1);

$temp2 'Template2:{{content2}}';
$tpl2 JspitTemplate::createFromString($temp2);

$temp3 'Name:{{name ?? "defName"}}';
$tpl3 JspitTemplate::createFromString($temp3);

$html $tpl1->assign([
  
"content" => $tpl2,
  
"content2" => $tpl3,
  
'name' => 'Harry'
])
->
getHtml()
;
$t->checkEqual($html,'From Template1 Template2:Name:Harry'); 
[0.049 ms]
'From Template1 Template2:Name:Harry'
Ok
check __tostring() 775 $str = (string)JspitTemplate::createFromString("ABC");
$t->checkEqual($str,"ABC"); 
[0.005 ms]
'ABC'
Ok
getPlaceholders() 780 /*
 * check internal methodes
 */
$strTpl = <<< 'TEMPLATE'
..{{ foo }}
..abc{{ foo.bar }}
..{{ foo|html }}
..{{ foo.bar|format("%3d")}}
..{{foo}}
..{{fo}}
TEMPLATE;
$result JspitTemplate::createFromString($strTpl)
  ->
getPlaceholders('foo')
;
$expected = array(
  
=> '{{foo}}',
  
=> '{{foo.bar}}',
  
=> '{{foo|html}}',
  
=> '{{foo.bar|format("%3d")}}',
);
$t->checkEqual($result$expected); 
[0.016 ms]
array ( 0 => '{{foo}}', 1 => '{{foo.bar}}', 2 => '{{foo|html}}', 3 => '{{foo.bar ..
Ok
splitPlaceholder 803 $placeHolder '{{foo.bar|format("%3d")|html??"default value"}}';
$result JspitTemplate::splitPlaceholder($placeHolder);
$expected = [
  
'name' => ['foo','bar'],
  
'filter' => ['format("%3d")','html'],
  
'default' => 'default value'
];
$t->checkEqual($result$expected); 
[0.006 ms]
array ( 'name' => array ( 0 => 'foo', 1 => 'bar', ), 'filter' => array ( 0 => 'f ..
Ok
stripQuotes: No quotes 813 $result JspitTemplate::stripQuotes('No quotes');
$t->checkEqual($result'No quotes'); 
[0.001 ms]
'No quotes'
Ok
stripQuotes: "Double quoted" 817 $result JspitTemplate::stripQuotes('"Double quoted"');
$t->checkEqual($result'Double quoted'); 
[0.001 ms]
'Double quoted'
Ok
stripQuotes: 'Single quoted' 821 $result JspitTemplate::stripQuotes("'Single quoted'");
$t->checkEqual($result'Single quoted'); 
[0.001 ms]
'Single quoted'
Ok
stripQuotes: "One of each' 825 $result JspitTemplate::stripQuotes("\"One of each'");
$t->checkEqual($result"\"One of each'"); 
[0.001 ms]
'"One of each\''
Ok