Question about truncate truncated characters in smarty

Source: Internet
Author: User
In smarty, truncate and spacify are used together to intercept the question template file index. the code in tpl is as follows: {code ...} index. the code in php is as follows: {code ...} the result of code execution is: SmokersarePr... but according to my thinking, the following section... question about truncate and spacify used in combination in smarty to intercept characters
The code in index. tpl of the template file is as follows:

<{* Mediation is all lowercase letters, and a space is inserted between each character. Then, the default length is 80 characters. *}> <{$ articleTitle | spacify | truncate: 30: "... "}>

The code in index. php is as follows:

$smarty->assign('articleTitle', 'Smokers are Productive, but Death Cuts Efficiency.');$smarty->display('index.tpl');

The code runs as follows:
S m o k e r s a r e P r...

However, based on my thinking, the following code is provided:

 <{$articleTitle|spacify|truncate:30:"..."}> 

(1) Insert spaces between Characters Based on spacify to get: S m o k e r s a r e P r o d u c t I v e
(2) then use truncate: 5: "..." to intercept the characters in (1) and the result is:
S m o k e r s a r e P r o d...
However, because truncate intercepts words by default, the final result should be:
S m o k e r s a r e... This is different from the running result ????

Reply content:

Question about truncate and spacify used in combination in smarty to intercept characters
The code in index. tpl of the template file is as follows:

<{* Mediation is all lowercase letters, and a space is inserted between each character. Then, the default length is 80 characters. *}> <{$ articleTitle | spacify | truncate: 30: "... "}>

The code in index. php is as follows:

$smarty->assign('articleTitle', 'Smokers are Productive, but Death Cuts Efficiency.');$smarty->display('index.tpl');

The code runs as follows:
S m o k e r s a r e P r...

However, based on my thinking, the following code is provided:

 <{$articleTitle|spacify|truncate:30:"..."}> 

(1) Insert spaces between Characters Based on spacify to get: S m o k e r s a r e P r o d u c t I v e
(2) then use truncate: 5: "..." to intercept the characters in (1) and the result is:
S m o k e r s a r e P r o d...
However, because truncate intercepts words by default, the final result should be:
S m o k e r s a r e... This is different from the running result ????

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.