New template processing class, interested can try

Source: Internet
Author: User
Tags definition variable
Main features of template pfctemplate
1. High efficiency
Because the program analysis variables, blocks are not used to do formal expressions, and the use of PHP built-in strings
Processing function, so the efficiency may be slightly higher than the same product

2. Ease of Use
Use this class to simply create a class instance-> add a file-> set a variable/chunk-> [parse if there is a chunk]
-> parsing file can be completed. The common naming method is used to provide an easy to understand API interface.

3. Multi-level block processing
Many complex effects can be achieved through the multilevel block processing function of the program, which can be nested at infinite level (machine performance permitting)

4. Templates that can handle multiple sources
Templates do not have to be made into files, either from a database or from another source.

$str = Read_template_string ();

$tpl->set_string (' Handle1 ', $str);

5. Variable Customizable

Identifiers in the template can be adjusted by themselves.

For example, to customize the identifier of a simple variable to "{/var/}", simply call the following:

$tpl->varbegin = ' {/';
$tpl->varend = '/} ';

Set the definition of a chunk to: "<!--name-->content<!--/name-->", just:

$tpl->blockstartbegin = ' <!--';
$tpl->blockstartend = '--> ';

$tpl->blockendbegin = ' <!--/';
$tpl->blockendend = '--> ';

This allows the class to be compatible with similar products such as Phplib's template, Fasttemplate, and Smart.


Pfctemplate description

I don't have the ability to add caching to the class, and I think the smart cache is essentially parsed in PHP. For newer and faster websites, it is not suitable for smart

To do is universally acknowledged. But for updates that are not a lot of Web sites, using smart is actually not as good as adding HTML files to your program. Web server processing

The speed of HTML is much faster than PHP.

If you think it is inconvenient to add a parameter to the best row when parsing chunks, you can modify this class to clear the last block definition at the time of the output.
But the result will be a little slower than it is now. Look at the needs of your project to compromise it!



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.