yet another template class

From: Date: Thu, 01 Nov 2001 00:08:56 +0000
Subject: yet another template class
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-2498@lists.php.net to get a copy of this message
Hi, I created my own template class that is multi-byte safe, and consumes lower computing resource by using (mb_)strpos, (mb_)substr,(mb_)strlen, and str_replace(when multi-byte is disabled) instead of preg* or ereg*, mbreg*(multi-byte safe regular expression imported from Ruby. This needs external package when compiling PHP). Not using regular expression resulted in stricter syntax in template file and speed gain. The reason why I did not use PHPLIB based PEAR template or IT is that I was worried if these classes are multi-byte safe, and they consume CPU resource that are already exhausted by SQL queries. I created this class while developing fairly complex DB driven B2B system, and the site's default language is in Japanese. It does not use handler. Instead, assignment function that returns unique id used to access the variable or block later. It supports variable replacement, block that can be set to hidden or shown, loop, multple-depth loop, and include statement in template file that gives web designer the authority and independence. They no longer need to ask programmer which file they want to include. Syntax in template file variable replacement: [%name%] block that can be set to hidden or shown [%BLOCK_EYECOLOR_BEGIN%] [%eye_color%] [%BLOCK_EYECOLOR_END%] multiple-depth loop [%LOOP_fruit_BEGIN%] [%LOOP_fruit.apple_BEGIN%] [%fruit.apple.color%] [%color%] <!-- this variable is different from one in above--> [%LOOP_fruit.apple__END%] [%LOOP__fruit_END%] You can always change prepend and append delimiter "[%" and "%]" to anything you like by setPrepend($new) and setAppend($new). If any of you are interested, I will set up web page for this and donate my code to PEAR. Give me your thoughts. Naoki Shima

« previous php.pear.dev (#2498) next »