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 ????