PEAR HTML_Template_IT board class usage

Source: Internet
Author: User
Tags pear online

HTML_Template_IT in PEAR is a simple and easy to use class. * ********* Create a template file ****************** the "symbol" Naming rule is the following regular expression: {[0-9A-Za-z _-] +} "block is in the following format. The block name naming rules are the same as the" symbol: ... Block content... Blocks allow nesting. You must first set and analyze the innermost blocks, and then set and analyze the blocks at the upper layer. * Main method: void IntegratedTemplate :: integratedTemplate ([string $ root = ""]) $ root = touch board root directory you can also use void IntegratedTemplate: setRoot (string $ root) to set the template directory; this method cannot be called statically. Pipeline loading template: boolean IntegratedTemplate: loadTemplatefile (string $ filename, boolean [$ removeUnknownVariables = TRUE], boolean [$ removeEmptyBlocks = TRUE]) $ filename = template file name $ removeUnknownVariables = sets whether to remove unknown variables $ removeEmptyBlocks = sets whether to successfully remove empty blocks, returns TRUE, and returns FALSE if not. This method cannot be statically called ------------------------------------------------------- specifies the block to be processed: boolean IntegratedTemplate: setCurrentBlock ([string $ block = "_ global"]) $ block = if the block name is successful, TRUE is returned. If the block name fails, a PEAR_Error object is returned, which contains the error description. This method cannot be called statically. Using variables to replace the "symbol" in the block to be processed: void IntegratedTemplate: setVariable (mixed $ placeholder [, mixed $ variable = ""]) $ placeholder = Name of the symbol to be replaced. If $ variable is an array, use the symbol name as the index of the array and replace the symbol $ variable = variable name or array name with the data of the indexed array element. The function cannot be statically called -------------------------------------------- analyze the current processing block: void IntegratedTemplate: parsecurityblock () will return a PEAR_Error object if it fails, Contains the error description. This method cannot be called statically. ------------------------------------------------------- Output after processing is completed: void IntegratedTemplate: show ([string $ block]) $ block = $ block is not set for the block to be returned, the complete template ********************** is returned as a simple example (the example is from the PEAR online manual) * *** Usage Example 25-1. main.tpl.htm template file, in ". /templates "Directory {DATA} Example 25-2. PHP script Array ("Stig", "Bakken"), "1" => array ("Martin", "Jansen"), "2" => array ("Alexander ", "Merz"); $ tpl = new HTML_Template_IT (". /templates "); $ tpl-> loadTemplatefile (" main.tpl.htm ", true, true); foreach ($ data as $ name) {foreach ($ name as $ cell) {// Assign data to the inner block $ tpl-> setCurrentBlock ("cell"); $ tpl-> setVariable ("DATA", $ cell ); $ tpl-> parsecurityblock ("cell");} // Assign data and t He inner block to the // outer block $ tpl-> setCurrentBlock ("row"); $ tpl-> parsecur1_block ("row ");} // output $ tpl-> show ();?> Example 25-3. OutputStig Bakken Martin Jansen Alexander Merz**************************************** * ************** There is an ITX class in HTML_Template_IT, IT can complete more complex functions and inherit from IT classes; ITX. The original code of the PHP file contains the method description of this class. For more information about other HTML_Template_IT methods, see the PEAR manual, address for http://pear.php.net/manual/en/package.html.html-template-it.php-hope you can take advantage of PEAR this library to write more and better PHP programs! --

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.