Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 148 Revision 991
Zeile 1... Zeile -...
1
wordwrap {#language.modifier.wordwrap}
-
 
2
========
1
# wordwrap
Zeile 3... Zeile 2...
3
 
2
 
4
Wraps a string to a column width, the default is 80. As an optional
3
Wraps a string to a column width, the default is 80. As an optional
5
second parameter, you can specify a string of text to wrap the text to
4
second parameter, you can specify a string of text to wrap the text to
6
the next line, the default is a carriage return `"\n"`. By default,
5
the next line, the default is a carriage return `"\n"`. By default,
7
`wordwrap` will attempt to wrap at a word boundary. If you want to cut
6
`wordwrap` will attempt to wrap at a word boundary. If you want to cut
8
off at the exact character length, pass the optional third parameter as
7
off at the exact character length, pass the optional third parameter as
9
TRUE. This is equivalent to the PHP
8
TRUE. This is equivalent to the PHP
Zeile 10... Zeile 9...
10
[`wordwrap()`](&url.php-manual;wordwrap) function.
9
[`wordwrap()`](https://www.php.net/wordwrap) function.
11
 
-
 
12
   Parameter Position    Type     Required   Default  Description
-
 
-
 
10
 
13
  -------------------- --------- ---------- --------- ------------------------------------------------------------------------------------------------------
11
## Basic usage
14
           1            integer      No        80     This determines how many columns to wrap to.
-
 
-
 
12
```smarty
Zeile -... Zeile 13...
-
 
13
{$myVar|wordwrap:30}
Zeile 15... Zeile -...
15
           2            string       No        \\n    This is the string used to wrap words with.
-
 
-
 
14
```
-
 
15
 
-
 
16
## Parameters
-
 
17
 
-
 
18
| Parameter Position | Type    | Required | Default | Description                                                                                   |
Zeile 16... Zeile -...
16
           3            boolean      No       FALSE   This determines whether or not to wrap at a word boundary (FALSE), or at the exact character (TRUE).
-
 
17
 
-
 
18
 
19
|--------------------|---------|----------|---------|-----------------------------------------------------------------------------------------------|
Zeile 19... Zeile 20...
19
    <?php
20
| 1                  | integer | No       | 80      | This determines how many columns to wrap to.                                                  |
-
 
21
| 2                  | string  | No       | \\n     | This is the string used to wrap words with.                                                   |
Zeile 20... Zeile -...
20
 
-
 
21
    $smarty->assign('articleTitle',
-
 
-
 
22
| 3                  | boolean | No       | FALSE   | This determines whether to wrap at a word boundary (FALSE), or at the exact character (TRUE). |
-
 
23
 
22
                    "Blind woman gets new kidney from dad she hasn't seen in years."
24
## Examples
Zeile -... Zeile 25...
-
 
25
 
Zeile 23... Zeile 26...
23
                   );
26
```php
Zeile -... Zeile 27...
-
 
27
<?php
24
 
28
 
Zeile 25... Zeile 29...
25
    ?>
29
$smarty->assign('articleTitle',
Zeile 26... Zeile 30...
26
 
30
                "Blind woman gets new kidney from dad she hasn't seen in years."
Zeile 27... Zeile 31...
27
       
31
               );
Zeile -... Zeile 32...
-
 
32
 
28
 
33
```
Zeile 29... Zeile 34...
29
Where template is
34
 
Zeile -... Zeile 35...
-
 
35
Where template is
-
 
36
 
Zeile 30... Zeile -...
30
 
-
 
31
 
-
 
32
    {$articleTitle}
37
```smarty
33
 
38
{$articleTitle}
34
    {$articleTitle|wordwrap:30}
39
 
35
 
40
{$articleTitle|wordwrap:30}
36
    {$articleTitle|wordwrap:20}
41
 
37
 
42
{$articleTitle|wordwrap:20}
38
    {$articleTitle|wordwrap:30:"<br />\n"}
43
 
39
 
44
{$articleTitle|wordwrap:30:"<br />\n"}
40
    {$articleTitle|wordwrap:26:"\n":true}
45
 
41
 
46
{$articleTitle|wordwrap:26:"\n":true}
42
       
47
```
43
 
48
 
44
Will output:
49
Will output:
45
 
50
 
46
 
51
```html
47
    Blind woman gets new kidney from dad she hasn't seen in years.
52
Blind woman gets new kidney from dad she hasn't seen in years.
48
 
-
 
49
    Blind woman gets new kidney
53
 
Zeile 50... Zeile 54...
50
    from dad she hasn't seen in
54
Blind woman gets new kidney
51
    years.
55
from dad she hasn't seen in