什么是 Smarty?
为什么使用它?
使用案例与工作流
语法比较
模板继承
最佳做法
速成课程
此操作在每行缩进一个字符串,默认值为 4。作为可选参数,可以指定缩进的字符数。作为可选的第二个参数,可以使用要缩进的字符,例如,对于 tab,使用"\t"
。
参数位置 | 类型 | 要求 | 默认 | 说明 |
---|---|---|---|---|
1 | 整数 | 否 | 4 | 此变量将确定要缩进到的字符数。 |
2 | 字符串 | 否 | (一个空格) | 这是用来缩进的字符。 |
示例 5.12。缩进
<?php $smarty->assign('articleTitle', 'NJ judge to rule on nude beach. Sun or rain expected today, dark tonight. Statistics show that teen pregnancy drops off significantly after 25.' ); ?>
在模板中
{$articleTitle} {$articleTitle|indent} {$articleTitle|indent:10} {$articleTitle|indent:1:"\t"}
将输出
NJ judge to rule on nude beach. Sun or rain expected today, dark tonight. Statistics show that teen pregnancy drops off significantly after 25. NJ judge to rule on nude beach. Sun or rain expected today, dark tonight. Statistics show that teen pregnancy drops off significantly after 25. NJ judge to rule on nude beach. Sun or rain expected today, dark tonight. Statistics show that teen pregnancy drops off significantly after 25. NJ judge to rule on nude beach. Sun or rain expected today, dark tonight. Statistics show that teen pregnancy drops off significantly after 25.