indent

    每行的字符串进行缩进,缺省为4个空格。作为一个可选参数,你可以制定缩进字符的个数。作为可选的第二个参数,可以指定缩进用的字符,如用"\t"作为制表符。

参数位置 类型 必需? 缺省 描述
1integerNo4 指定缩进多少个字符
2stringNo 空格 用来缩进的字符

例子5-12. indent

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

    参见stripwordwrap以及spacify