Template engine-What does a template tag in a thinkphp do for a specific purpose?

Source: Internet
Author: User
Tags php form
TP has a lot of built-in labels, judging comparisons, loops, and so on, using PHP to do the service side of the development of the front end with more, personally think these tags will complicate the readability of HTML, and the front and back of the engineer should not waste time on these labels ...

I thought about two points:

    1. To say inheritance, the previous project with CI rewrite the Load object, but also with PHP to assemble HTML. There will be no hard-to-find place in this area.

    2. If the front and back end of the separation, I think web development itself is a need for a relatively broad knowledge of the work, and must have a docking part, using the template engine after the front end still has to write a lot of template variables (less than a few characters this is true ...) )。

Finally, it is thought that the program should be considered to solve the problem, and consider performance first. So not very understanding of the original design of the template, TP source code is not fully read, do not understand the performance of these built-in tags problems.

Just started with TP, maybe I have the wrong understanding don't despise me ...

Reply content:

TP has a lot of built-in labels, judging comparisons, loops, and so on, using PHP to do the service side of the development of the front end with more, personally think these tags will complicate the readability of HTML, and the front and back of the engineer should not waste time on these labels ...

I thought about two points:

    1. To say inheritance, the previous project with CI rewrite the Load object, but also with PHP to assemble HTML. There will be no hard-to-find place in this area.

    2. If the front and back end of the separation, I think web development itself is a need for a relatively broad knowledge of the work, and must have a docking part, using the template engine after the front end still has to write a lot of template variables (less than a few characters this is true ...) )。

Finally, it is thought that the program should be considered to solve the problem, and consider performance first. So not very understanding of the original design of the template, TP source code is not fully read, do not understand the performance of these built-in tags problems.

Just started with TP, maybe I have the wrong understanding don't despise me ...

With the native PHP code, and the template, the final effect is the same, the template will be parsed into the native code. To say efficiency, the feeling is not very different.

I think that since you use the framework, it is of course to use their templates to write code better, after all, the developers of each template, have been thoughtful to do a variety of convenient settings. You have to write native PHP, then you need to use the framework, and if you do not follow the framework of the specification development, for you later faster use of the framework is also not benefit.

Framework is easy for us to develop faster, but in the use of the framework, the basic principles, but also need their own deep learning, the foundation is still solid.

I feel the role of template tags is to write less PHP in HTML
PHP is a very flexible language, there is no template engine constraints, I feel that the front-end HTML code will embed PHP very much, and maybe even some people function is defined in the inside, or some logic is written in the inside, but with the template engine to do so few people, whether it is not a novice
Performance what does not need to pay too much attention, even if using the template engine, you can parse it into HTML mixed PHP form to cache it, theoretically you just the first time through the regular resolution, the second can not be resolved again.

Just for the front-end separation, the template engine is much the same, and the front-end developer learns its usage costs far less than the cost of learning a language.

The syntax coloring for the editor is normal

  • Related Article

    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.