#1
  1. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    Thessaloniki
    Posts
    1,270
    Rep Power
    12

    Question Embedding a for inside an html template for substitution


    Hello pythonistas!

    I'am tryign to populate a table with dictionary keys and values:

    Foe that iam using an html template and the questions is what i should write inside 'files.html' so then then the python script populate the table.

    Code:
    <table>
    	<tr><th>SuperHost - Economy</th></tr>
    	<tr><td>Χώρος στο δίσκο: 1 GB</td></tr>
    	<tr><td>Μηνιαία Κίνηση δεδομένων: 1 GB</td></tr>
    	<tr><td>Control Panel: cPanel 11 & Fantastico Deluxe</td></tr>
    	<tr><td>Domains: 1</td></tr>
    	<tr><td>Subdomains: 1</td></tr>
    	<tr><td>FTP Accounts: 1</td></tr>
    	<tr><td>Emails (POP3): 2</td></tr>
    	<tr><td>WebMail: [ RoundCube|Horde|Squirrel ]: ΝΑΙ</td></tr>
    	<tr><td>Mysql Databases: 2</td></tr>
    </table>
    Intead of writing the above html data inside my html template how would i write itr with a for that then will be substituted by the python script?

    Thank you.
    What is now proved was once only imagined!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    138
    Rep Power
    2
    Originally Posted by Nik
    Hello pythonistas!

    I'am tryign to populate a table with dictionary keys and values:

    Foe that iam using an html template and the questions is what i should write inside 'files.html' so then then the python script populate the table.

    Code:
    <table>
    	<tr><th>SuperHost - Economy</th></tr>
    	<tr><td>Χώρος στο δίσκο: 1 GB</td></tr>
    	<tr><td>Μηνιαία Κίνηση δεδομένων: 1 GB</td></tr>
    	<tr><td>Control Panel: cPanel 11 & Fantastico Deluxe</td></tr>
    	<tr><td>Domains: 1</td></tr>
    	<tr><td>Subdomains: 1</td></tr>
    	<tr><td>FTP Accounts: 1</td></tr>
    	<tr><td>Emails (POP3): 2</td></tr>
    	<tr><td>WebMail: [ RoundCube|Horde|Squirrel ]: ΝΑΙ</td></tr>
    	<tr><td>Mysql Databases: 2</td></tr>
    </table>
    Intead of writing the above html data inside my html template how would i write itr with a for that then will be substituted by the python script?

    Thank you.
    I suggest you look into a python templating engine. There are several avalilable, so you'll have to decide which one is best for you.

    http://wiki.python.org/moin/Templating
  4. #3
  5. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    Thessaloniki
    Posts
    1,270
    Rep Power
    12
    Which one would you suggest? can you please write an example for me that user "files.html" and gets populates by "files.py" ?

    i want os ee how it lloks like please!
    What is now proved was once only imagined!
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    138
    Rep Power
    2
    Originally Posted by Nik
    Which one would you suggest? can you please write an example for me that user "files.html" and gets populates by "files.py" ?

    i want os ee how it lloks like please!
    I'm sorry, but I'm not familiar enough with python web templating engines to come with a recommendation. I'll let somebody more experienced answer your question.
  8. #5
  9. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    Thessaloniki
    Posts
    1,270
    Rep Power
    12
    is django one of html template systems?
    What is now proved was once only imagined!

IMN logo majestic logo threadwatch logo seochat tools logo