0

Getting plaintext files from an HTML template using python code.

Like Django, using jinja templating from the jinja2 library to display data parsed into the context from the view function.

I'll like to know all the different ways in which I can get the plaintext version of the jinja template, and most of all "it should be formatted".

Example

  • Jinja template
<div>{{ book.name }}</div>
  <p> The author of the book is {{ book.author }}.</p>
  <p> For more description, go to "{{ book.url }}"</p>
  <div> <p>Some important notions on the book</p>
   <ol>
     {% for items in points %}
       <li>{{ items }}</li>
     {% endfor %}
   </ol>
  </div>
</div>
  • Plaintext version
Python For Beginners
The author of the book is John Doe.
For more description, go to "https://mybooks.example.com/book1"
  Some important notions on the book
    - Variable
    - Strings
    - File R/W operations
    - Loops
    - Conditions

what different options can I have to do this in Django or python and getting over a 100 of such files from the database.

0 Answers0