阅读(2388) (1)

Smarty:indent

2016-10-12 15:33:44 更新

indent

缩进每一行的字符串,默认是缩进4个空格。 可选的参数可以设置缩进的空格数量。 可选的第二个参数设置缩进使用的字符,如用 "\t" 来代替空格缩进。

参数顺序类型必选参数默认值说明
1integerNo4设置缩进多少空格
2stringNo一个空格设置用什么字符来进行缩进

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