| 991 |
lars |
1 |
# indent
|
| 148 |
lars |
2 |
|
|
|
3 |
This indents a string on each line, default is 4. As an optional
|
|
|
4 |
parameter, you can specify the number of characters to indent. As an
|
|
|
5 |
optional second parameter, you can specify the character to use to
|
| 991 |
lars |
6 |
indent with. For example: use `"\t"` for a tab.
|
| 148 |
lars |
7 |
|
| 991 |
lars |
8 |
## Basic usage
|
|
|
9 |
```smarty
|
|
|
10 |
{$myVar|indent:4}
|
|
|
11 |
```
|
| 148 |
lars |
12 |
|
| 991 |
lars |
13 |
## Parameters
|
| 148 |
lars |
14 |
|
| 991 |
lars |
15 |
| Parameter Position | Type | Required | Default | Description |
|
|
|
16 |
|--------------------|---------|----------|-------------|---------------------------------------------------|
|
|
|
17 |
| 1 | integer | No | 4 | This determines how many characters to indent to. |
|
|
|
18 |
| 2 | string | No | (one space) | This is the character used to indent with. |
|
| 148 |
lars |
19 |
|
| 991 |
lars |
20 |
## Examples
|
| 148 |
lars |
21 |
|
| 991 |
lars |
22 |
```php
|
|
|
23 |
<?php
|
| 148 |
lars |
24 |
|
| 991 |
lars |
25 |
$smarty->assign('articleTitle',
|
|
|
26 |
'NJ judge to rule on nude beach.
|
|
|
27 |
Sun or rain expected today, dark tonight.
|
|
|
28 |
Statistics show that teen pregnancy drops off significantly after 25.'
|
|
|
29 |
);
|
|
|
30 |
```
|
|
|
31 |
|
| 148 |
lars |
32 |
Where template is:
|
|
|
33 |
|
| 991 |
lars |
34 |
```smarty
|
|
|
35 |
{$articleTitle}
|
| 148 |
lars |
36 |
|
| 991 |
lars |
37 |
{$articleTitle|indent}
|
| 148 |
lars |
38 |
|
| 991 |
lars |
39 |
{$articleTitle|indent:10}
|
| 148 |
lars |
40 |
|
| 991 |
lars |
41 |
{$articleTitle|indent:1:"\t"}
|
|
|
42 |
```
|
| 148 |
lars |
43 |
|
|
|
44 |
Will output:
|
|
|
45 |
|
| 991 |
lars |
46 |
```
|
|
|
47 |
NJ judge to rule on nude beach.
|
|
|
48 |
Sun or rain expected today, dark tonight.
|
|
|
49 |
Statistics show that teen pregnancy drops off significantly after 25.
|
| 148 |
lars |
50 |
|
|
|
51 |
NJ judge to rule on nude beach.
|
|
|
52 |
Sun or rain expected today, dark tonight.
|
|
|
53 |
Statistics show that teen pregnancy drops off significantly after 25.
|
|
|
54 |
|
| 991 |
lars |
55 |
NJ judge to rule on nude beach.
|
|
|
56 |
Sun or rain expected today, dark tonight.
|
|
|
57 |
Statistics show that teen pregnancy drops off significantly after 25.
|
|
|
58 |
|
| 148 |
lars |
59 |
NJ judge to rule on nude beach.
|
|
|
60 |
Sun or rain expected today, dark tonight.
|
|
|
61 |
Statistics show that teen pregnancy drops off significantly after 25.
|
| 991 |
lars |
62 |
```
|
| 148 |
lars |
63 |
|
|
|
64 |
|
| 991 |
lars |
65 |
See also [`strip`](language-modifier-strip.md),
|
|
|
66 |
[`wordwrap`](language-modifier-wordwrap.md) and
|
|
|
67 |
[`spacify`](language-modifier-spacify.md).
|