|
Posted by the DtTvB on 05/28/06 14:58
I made one
Source file: http://dttvb.yi.org/tparser.phps
There are still some problems about nesting. But it works quite well.
-- TESTS --
echo dtsparse('[[if 2==2]]this condition is true[[else]]this condition
is false[[endif]]');
// Outputs this condition is true
echo dtsparse('[[if 3==2]]this condition is true[[else]]this condition
is false[[endif]]');
// Outputs this condition is false
echo dtsparse('[[if 3>2]]this condition is true[[else]]this condition
is false[[endif]]');
// Outputs this condition is true
echo dtsparse('before if[[if 3==3]], this condition is true[[endif]],
after if');
// Outputs before if, this condition is true, after if
echo dtsparse('before if[[if 3==2]], this condition is true[[endif]],
after if');
// Outputs before if, after if
echo dtsparse('[[for 5,10]]aa [[endfor]]');
// Outputs aa aa aa aa aa aa
echo dtsparse('[[for 5 to 10]][[index]],[[endfor]]finish');
// Outputs 5,6,7,8,9,10,finish
Is that what you want? Sorry if it's not.
Navigation:
[Reply to this message]
|