0

What's the easiest way to control taking strings to html, where you can feed attributes easily like the id, classes, etc, such that in one line you can pass a string:

'just install in crontab:\n    \n    crontab -e\n    \n    * * * * * /usr/bin/python ~/path/update_files.py'

and get

<p>just install in crontab:</p><p> </p><p> crontab -e</p><p> </p><p> * * * * * /usr/bin/python ~/path/update_files.py</p>

Thank you

1 Answer 1

1

You can use Django filters to convert your plain text newlines into HTML. linebreaks turns single newlines into <br> tags, and double newlines into <p> tags. linebreaksbr just turns newlines into <br> tags:

{{value|linebreaks}}
{{value|linebreaksbr}}
Sign up to request clarification or add additional context in comments.

1 Comment

I want to control the html w python, like maybe make each like <p class='orange'> or <button value={{ python_attr }}>. your answer works for one use case but not most

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.