Variable modifiers and function descriptions in five Smarty

Source: Internet
Author: User
This article mainly introduced about five smarty in the variable modifier and function description, has a certain reference value, now share to everyone, the need for friends can refer to

Default

For example: {$arr |default: ' xxxx '}, default variable adjuster, displays the given default value when the variable is empty, sets a default value for the null variable, and replaces the output with the given default value when the variable is empty or unassigned.

Truncate

For example: {$articleTitle |truncate:10}, the length of the cut string is the specified length, and the character of a length is truncated from the beginning of the string, which is 80 by default.

Count_characters

For example: {$articleTitle |count_characters}, gets the length of the string, calculates the number of characters in the variable value, and the parameter value the Brown type determines whether the number of spaces is calculated, and no space is calculated by default.

Strip_tags

For example: {$articleTitle |strip_tags}, remove all HTML tags from the string;

Date_format

For example: {$smarty. Now|date_format (")}, format timestamp, date format, first parameter control date format, if the data passed to Date_format is empty, the second parameter will be used as the default time.

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.