7. ctemplate advanced [from 1]

Source: Internet
Author: User

1. ctemplate advanced [from 1]

Modifier (modifier), the type of common variables (HTML, JS, or other), will undergo verification and encoding, for example, HTML type will convert & &. Types include HTML, pre, URL query, JavaScript, CSS, and JSON. If you find it difficult to define the template variables, you can use the Google: Template: gettemplatewithautoescaping () method to load the template, and use the automatic replacement mode to specify whether it is HTML, JS or CSS. You can write your own modifier to handle some special requirements.

Strip. The template contains some blank lines and blank characters. During loading, you can specify the parameter to determine whether to clear it. For example, Google: strip_blk_lines, Google: strip_whitespace.

Expandemitter, which has this interface in ctemplate. This interface is used to output data when the template is expanded. The stringemitter of STD: String version is implemented by default. After processing is completed, can be sent to the client, STD: String performance is not high. If you want an efficient web server, you can use the stream mode. For example, you can implement the expandemitter interface to stream data to the client browser.

Dictionary copy. If the two dictionaries are similar, copy a dictionary and modify it. Call dict-> makecopy ().

Reference

[1]Http://hi.baidu.com/duanmuchun/blog/item/eab82273b1a8861b8701b0bd.html

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.