[web2py] Re: HTML in context_dict for sending mails
This does not work. Still facing the same issue. On Monday, June 4, 2012 8:57:34 PM UTC+5:30, Anthony wrote: By default, the template engine escapes everything -- to avoid that, do: links = XML(lia href='app_path/view/user_a'user_a/a/li) See http://web2py.com/books/default/chapter/29/5#XML. Anthony On Monday, June 4, 2012 10:52:07 AM UTC-4, Sushant Taneja wrote: Hi All, I have a string var containing some HTML code links = lia href='app_path/view/user_a'user_a/a/li I am passing this variable to response.render function as: context_dict = dict(links=links) message = response.render(invite_friend.html,context_dict) # Send mail code below In invite_friend.html I have the code: html Hello there, ul {{=links}} ul /html When the mail is sent, the email message is rendered as below: Hello there, lia href='app_path/view/user_a'user_a/a/li instead of Hello there, - user_a http://# How to render the above mail properly ?? I am working on GAE and mail.settings.server is set to 'gae'
[web2py] Re: HTML in context_dict for sending mails
Here's your original method: links = lia href='app_path/view/user_a'user_a/a/li print response.render('invite_friend.html', dict(links=links)) html Hello there, ul lt;ligt;lt;a href= #x27;app_path/view/user_a#x27;gt;user_alt;/agt;lt;/ligt; ul /html As you can see, the HTML tags in links are getting escaped in the call to response.render(), so the HTML displays literally in the output instead of being rendered as HTML. Now, here it is wrapping the links HTML in XML(): links = XML(lia href='app_path/view/user_a'user_a/a/li) print response.render('invite_friend.html', dict(links=links)) html Hello there, ul lia href='app_path/view/user_a'user_a/a/li ul /html Now the links HTML is being rendered properly. One problem I notice, though, is that your have ul instead of /ul to close the list -- maybe that's why it's still not rendering as you expect. Anthony On Tuesday, June 5, 2012 5:17:08 AM UTC-4, Sushant Taneja wrote: This does not work. Still facing the same issue. On Monday, June 4, 2012 8:57:34 PM UTC+5:30, Anthony wrote: By default, the template engine escapes everything -- to avoid that, do: links = XML(lia href='app_path/view/user_a'user_a/a/li) See http://web2py.com/books/default/chapter/29/5#XML. Anthony
[web2py] Re: HTML in context_dict for sending mails
By default, the template engine escapes everything -- to avoid that, do: links = XML(lia href='app_path/view/user_a'user_a/a/li) See http://web2py.com/books/default/chapter/29/5#XML. Anthony On Monday, June 4, 2012 10:52:07 AM UTC-4, Sushant Taneja wrote: Hi All, I have a string var containing some HTML code links = lia href='app_path/view/user_a'user_a/a/li I am passing this variable to response.render function as: context_dict = dict(links=links) message = response.render(invite_friend.html,context_dict) # Send mail code below In invite_friend.html I have the code: html Hello there, ul {{=links}} ul /html When the mail is sent, the email message is rendered as below: Hello there, lia href='app_path/view/user_a'user_a/a/li instead of Hello there, - user_a http://# How to render the above mail properly ?? I am working on GAE and mail.settings.server is set to 'gae'
[web2py] Re: HTML in context_dict for sending mails
are you sending the string as the HTML part of the email: send(to=customer.email, subject=Plain text subject, message=(text_message, html_message) both my messages are from response.render (and neither sent through XML()). cfh On Monday, June 4, 2012 7:52:07 AM UTC-7, Sushant Taneja wrote: Hi All, I have a string var containing some HTML code links = lia href='app_path/view/user_a'user_a/a/li I am passing this variable to response.render function as: context_dict = dict(links=links) message = response.render(invite_friend.html,context_dict) # Send mail code below In invite_friend.html I have the code: html Hello there, ul {{=links}} ul /html When the mail is sent, the email message is rendered as below: Hello there, lia href='app_path/view/user_a'user_a/a/li instead of Hello there, - user_a http://# How to render the above mail properly ?? I am working on GAE and mail.settings.server is set to 'gae'