Subversion-Projekte lars-tiefland.laravel_shop

Revision

Zur aktuellen Revision | Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
wordwrap {#language.modifier.wordwrap}
2
========
3
 
4
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
6
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
8
off at the exact character length, pass the optional third parameter as
9
TRUE. This is equivalent to the PHP
10
[`wordwrap()`](&url.php-manual;wordwrap) function.
11
 
12
   Parameter Position    Type     Required   Default  Description
13
  -------------------- --------- ---------- --------- ------------------------------------------------------------------------------------------------------
14
           1            integer      No        80     This determines how many columns to wrap to.
15
           2            string       No        \\n    This is the string used to wrap words with.
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
    <?php
20
 
21
    $smarty->assign('articleTitle',
22
                    "Blind woman gets new kidney from dad she hasn't seen in years."
23
                   );
24
 
25
    ?>
26
 
27
 
28
 
29
Where template is
30
 
31
 
32
    {$articleTitle}
33
 
34
    {$articleTitle|wordwrap:30}
35
 
36
    {$articleTitle|wordwrap:20}
37
 
38
    {$articleTitle|wordwrap:30:"<br />\n"}
39
 
40
    {$articleTitle|wordwrap:26:"\n":true}
41
 
42
 
43
 
44
Will output:
45
 
46
 
47
    Blind woman gets new kidney from dad she hasn't seen in years.
48
 
49
    Blind woman gets new kidney
50
    from dad she hasn't seen in
51
    years.
52
 
53
    Blind woman gets new
54
    kidney from dad she
55
    hasn't seen in
56
    years.
57
 
58
    Blind woman gets new kidney<br />
59
    from dad she hasn't seen in<br />
60
    years.
61
 
62
    Blind woman gets new kidn
63
    ey from dad she hasn't se
64
    en in years.
65
 
66
 
67
 
68
See also [`nl2br`](#language.modifier.nl2br) and
69
[`{textformat}`](#language.function.textformat).