0

I searched around and doesn't seem to have any good solutions.

The closest one: django-pygments doesn't support template context/variable passing as language option.

I want to know if anyone one know of a good solution that supports snippet type passed as template context?

Thanks.

2
  • 1
    How about a JavaScript solution, like SHJS? Commented Jan 25, 2012 at 6:24
  • @JoachimPileborg Thanks. I am going to take a look at this. I tried highlight.js and I don't know why it didn't work. Commented Jan 25, 2012 at 6:45

1 Answer 1

1

Template:

{% content|pygmentize:lang %}

View:

def show(request):
    ctx = dict()
    ctx['content'] = 'alert("hello");'
    ctx['lang'] = 'javascript'
    return render(request,'template.html',ctx)
Sign up to request clarification or add additional context in comments.

2 Comments

Hi. Thanks. Is this the solution to django-pygments? Or doesit only require me to use python's pygement.
This is with django-pygments.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.