Discussion:
Does Symfony 2 support nl2br in twig?
Haulyn Jason
2011-07-14 05:14:06 UTC
Permalink
Hi,

I need to use nl2br, I find something in
vender/twig-extensions/lib/Twig/Extensions/Extension/Text.php, it
looks nl2br is support but I can not use {{content|nl2br}}, any
suggestions?


Regards,

Haulyn Jason
Founder, http://yunshang.org
Rm. 807, Qilu Software Tower, Qilu Software Park
1 Shunhua Rd., High-Tech Development Zone
Jinan, Shandong 250101, P. R. China
Tel: +86 158 5410 3759
Website: http://haulynjason.net
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Haulyn Jason
2011-07-15 05:30:07 UTC
Permalink
Is there a way to use nl2br via twig?


Regards,

Haulyn Jason
Founder, http://yunshang.org
Rm. 807, Qilu Software Tower, Qilu Software Park
1 Shunhua Rd., High-Tech Development Zone
Jinan, Shandong 250101, P. R. China
Tel: +86 158 5410 3759
Website: http://haulynjason.net
Post by Haulyn Jason
 Hi,
I need to use nl2br, I find something in
vender/twig-extensions/lib/Twig/Extensions/Extension/Text.php, it
looks nl2br is support but I can not use {{content|nl2br}}, any
suggestions?
Regards,
Haulyn Jason
Founder, http://yunshang.org
Rm. 807, Qilu Software Tower, Qilu Software Park
1 Shunhua Rd., High-Tech Development Zone
Jinan, Shandong 250101, P. R. China
Tel: +86 158 5410 3759
Website: http://haulynjason.net
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Aldwin Sabornido
2011-07-15 06:14:45 UTC
Permalink
You can create a twig extension.
Post by Haulyn Jason
Is there a way to use nl2br via twig?
Regards,
Haulyn Jason
Founder, http://yunshang.org
Rm. 807, Qilu Software Tower, Qilu Software Park
1 Shunhua Rd., High-Tech Development Zone
Jinan, Shandong 250101, P. R. China
Tel: +86 158 5410 3759
Website: http://haulynjason.net
Post by Haulyn Jason
Hi,
I need to use nl2br, I find something in
vender/twig-extensions/lib/Twig/Extensions/Extension/Text.php, it
looks nl2br is support but I can not use {{content|nl2br}}, any
suggestions?
Regards,
Haulyn Jason
Founder, http://yunshang.org
Rm. 807, Qilu Software Tower, Qilu Software Park
1 Shunhua Rd., High-Tech Development Zone
Jinan, Shandong 250101, P. R. China
Tel: +86 158 5410 3759
Website: http://haulynjason.net
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Haulyn Jason
2011-07-15 07:08:37 UTC
Permalink
Hi,

I am using the current Symfony 2 from git, I find a Text.php has nl2br
filter, but {{content|nl2br}} does not work. Anything else?

I find Text.php in vendor/twig-extensions/lib/Twig/Extensions/Extension

Regards,

Haulyn Jason
Founder, http://yunshang.org
Rm. 807, Qilu Software Tower, Qilu Software Park
1 Shunhua Rd., High-Tech Development Zone
Jinan, Shandong 250101, P. R. China
Tel: +86 158 5410 3759
Website: http://haulynjason.net
Post by Aldwin Sabornido
You can create a twig extension.
Post by Haulyn Jason
Is there a way to use nl2br via twig?
Regards,
Haulyn Jason
Founder, http://yunshang.org
Rm. 807, Qilu Software Tower, Qilu Software Park
1 Shunhua Rd., High-Tech Development Zone
Jinan, Shandong 250101, P. R. China
Tel: +86 158 5410 3759
Website: http://haulynjason.net
Post by Haulyn Jason
 Hi,
I need to use nl2br, I find something in
vender/twig-extensions/lib/Twig/Extensions/Extension/Text.php, it
looks nl2br is support but I can not use {{content|nl2br}}, any
suggestions?
Regards,
Haulyn Jason
Founder, http://yunshang.org
Rm. 807, Qilu Software Tower, Qilu Software Park
1 Shunhua Rd., High-Tech Development Zone
Jinan, Shandong 250101, P. R. China
Tel: +86 158 5410 3759
Website: http://haulynjason.net
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Michel Salib
2011-07-15 07:30:38 UTC
Permalink
Add this to your config.yml

services: text.twig.extension: class: Twig_Extensions_Extension_Text tags: - { name: twig.extension }
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Alejandro Hurtado
2011-07-15 06:45:01 UTC
Permalink
nl2br is a filter of the Twig_extesions included in the Text extension. You
need to enable the extension with:

// Acme/YourBundle/Resources/config/services.yml
services:
twig.extension.txt:
class: Twig_Extensions_Extension_Text
tags:
- { name: twig.extension }
Post by Haulyn Jason
Is there a way to use nl2br via twig?
Regards,
Haulyn Jason
Founder, http://yunshang.org
Rm. 807, Qilu Software Tower, Qilu Software Park
1 Shunhua Rd., High-Tech Development Zone
Jinan, Shandong 250101, P. R. China
Tel: +86 158 5410 3759
Website: http://haulynjason.net
Post by Haulyn Jason
Hi,
I need to use nl2br, I find something in
vender/twig-extensions/lib/Twig/Extensions/Extension/Text.php, it
looks nl2br is support but I can not use {{content|nl2br}}, any
suggestions?
Regards,
Haulyn Jason
Founder, http://yunshang.org
Rm. 807, Qilu Software Tower, Qilu Software Park
1 Shunhua Rd., High-Tech Development Zone
Jinan, Shandong 250101, P. R. China
Tel: +86 158 5410 3759
Website: http://haulynjason.net
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Grégoire Havekes
2011-07-25 15:29:39 UTC
Permalink
Is there any possibility to enable it globally (for all bundles)?

Thanks
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Félix-Antoine Paradis
2011-07-25 18:58:39 UTC
Permalink
Enable it in app/config/config.yml ?
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Grégoire Havekes
2011-07-27 13:17:24 UTC
Permalink
Thanks
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Haulyn Jason
2011-07-15 07:33:49 UTC
Permalink
Oh, that's the most important. Thanks. I thinks it's better to write
it into cookbook.


Regards,

Haulyn Jason
Founder, http://yunshang.org
Rm. 807, Qilu Software Tower, Qilu Software Park
1 Shunhua Rd., High-Tech Development Zone
Jinan, Shandong 250101, P. R. China
Tel: +86 158 5410 3759
Website: http://haulynjason.net
Post by Michel Salib
Add this to your config.yml
class: Twig_Extensions_Extension_Text
- { name: twig.extension }
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Loading...