What is Smarty?
Why use it?
Use Cases and Work Flow
Syntax Comparison
Template Inheritance
Best Practices
Crash Course
You may use the Smarty logo according to the trademark notice.
For sponsorship, advertising, news or other inquiries, contact us at:
Posição do Parâmetro | Tipo | Requerido | Padrão | Descrição |
---|---|---|---|---|
1 | integer | Não | 80 | Isto determina em quantas colunas quebrar. |
2 | string | Não | \n | Esta é a string usada para quebrar. |
3 | boolean | Não | false | Isto determina quando quebrar ou não ao final de uma palavra (false), ou no caractere exato (true). |
Isto quebra uma string para uma largura de coluna, o padrão é 80. Como segundo parâmetro opcional, você pode especificar a string que será usada para quebrar o texto para a próxima linha (o padrão é um retorno de carro \n). Por padrão, wordwrap irá tentar quebrar ao final de uma palavra. Se você quiser quebrar no tamanho exato de caracteres, passe o terceiro parâmetro, que é opcional, como true.
Example 5.23. wordwrap
index.php: $smarty = new Smarty; $smarty->assign('articleTitle', "Blind woman gets new kidney from dad she hasn't seen in years."); $smarty->display('index.tpl'); index.tpl: {$articleTitle} {$articleTitle|wordwrap:30} {$articleTitle|wordwrap:20} {$articleTitle|wordwrap:30:"<br>\n"} {$articleTitle|wordwrap:30:"\n":true} MOSTRA: Blind woman gets new kidney from dad she hasn't seen in years. Blind woman gets new kidney from dad she hasn't seen in years. Blind woman gets new kidney from dad she hasn't seen in years. Blind woman gets new kidney<br> from dad she hasn't seen in years. Blind woman gets new kidney fr om dad she hasn't seen in year s.