On Thu, May 12, 2011 at 1:13 PM, Jason <1jason.whatf...@gmail.com> wrote:
> Hi there,
> I have a letter stored in my database which I would like to write to a html
> page preserving the formatting. The letter is standard text, however has
> some non ascii characters e.g. £ $ and so on which means the letter takes a
> unicode type. In the letter I have replaced line breaks with <br> etc.
> However when I write this to a variable {{ letter }} within my html document
> the html mark up shows as text rather than formatting the document e.g.
> Hello John <br><br> This letter is to <b> confirm </b>
> etc.
> Is there a way I can have the contents of this variable interpreted as html?
> Cheers,
> J
>

Unicode/not unicode is an irrelevant issue here.

Many ways to get the desired output:

1) Use the 'safe' template filter to mark the string as safe to output raw
2) Use django.utils.safestring.mark_safe to mark the string as safe in your view
3) Use the autoescape template tag to disable output escaping when you
output the string
4) Don't convert newlines to <br>, use the 'linebreaksbr' template
filter to do it in when you output the string

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to