Форуми / Cotonti / Core Labs / Archive / Logic blocks for xtemplate

medar
#9621 09.03.2009 22:59
New xtemplate.class.php: http://www.cotonti.com/datas/users/xtemplate.class_45.rar
Added logic blocks and some improve of code.

Logic blocks:
<!-- IF <if_statement> -->
this will display if <if_statement> is true
<!-- ENDIF -->
in <if_statement> allowed all avaiable tpl-tags !

Examples:
<!-- IF {PHP.usr.profile.user_name} == "admin" -->
hello admin !
<!-- ENDIF -->

<!-- IF {PAGE_DESC}=="" -->
Description of this page is empty
<!-- ENDIF -->

<!-- IF {PAGE_DESC}=={PAGE_TITLE} AND {PAGE_COMMENTS_COUNT} > 0 -->
There is some comments here.
And title and description of this page are equal.
<!-- ENDIF -->

Benchmark:
CentOS 5, Apache 2, php 5.2.8
Testing:
ab -c 4 -n1000 "http://exampler.net/cotonti/page.php?id=2"

Old xtemplate
Requests per second: 16.30 [#/sec] (mean)

New xtemplate, tpl without IF
Requests per second: 17.47 [#/sec] (mean)

New xtemplate, tpl with 1 IF
Requests per second: 16.78 [#/sec] (mean)

New xtemplate, tpl with 25 IF
Requests per second: 15.60 [#/sec] (mean)

Please test, comment and i will commit it.
rangjungyeshe.ru