Smarty:indent

2018-10-12 15:33 更新

indent

縮進(jìn)每一行的字符串,默認(rèn)是縮進(jìn)4個(gè)空格。 可選的參數(shù)可以設(shè)置縮進(jìn)的空格數(shù)量。 可選的第二個(gè)參數(shù)設(shè)置縮進(jìn)使用的字符,如用 "\t" 來(lái)代替空格縮進(jìn)。

參數(shù)順序類(lèi)型必選參數(shù)默認(rèn)值說(shuō)明
1integerNo4設(shè)置縮進(jìn)多少空格
2stringNo一個(gè)空格設(shè)置用什么字符來(lái)進(jìn)行縮進(jìn)

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.

參見(jiàn) stripwordwrap 和 spacify.

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)