0

Is it possible to display html formatted text (for example 'Hey!') as html via jQuery? I`m getting this text from db. When im trying to do something like

   $('.course_content').find('.content').html('{{ course.description }}')

It looks like plain text

  <strong>Hey!</strong>

2 Answers 2

1

You can use the safe filter. An example usage is:

{{course.description|safe|escape}}

You can read up about it here

0

You can't do that because you are mixing server and client side execution. Django view code is executed in the server (so all the {{ value }} tags are replaced with the respective values), and what is returned to the web browser is just HTML. Then the javascript code is executed in the context of the HTML generated.

So, if you want to use client-side templates like you have on Django you can use something like Handlebar.js, which has a similar syntax.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.