Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5840153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:41:56+00:00 2026-05-22T11:41:56+00:00

I am making a table with web2py HTML helpers. My code is based on

  • 0

I am making a table with web2py HTML helpers. My code is based on the example from the web2py book:

>>> table = [['a', 'b'], ['c', 'd']]
>>> print TABLE(TR(*table[0]), TR(*table[1]))
<table><tr><td>a</td><td>b</td></tr><tr><td>c</td><td>d</td></tr></table>

I have quite a large table, but this approach places all output on one big line. For readability of the HTML, I would appreciate a way to add newlines after each </tr>. I like the HTML helper functions so prefer not to go for the plain {{for …}} … {{pass}} approach in the view.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T11:41:57+00:00Added an answer on May 22, 2026 at 11:41 am

    A line of python code to insert a ‘\n’ after every row end tag should do the trick. Something like this

    {{
    table = [['a', 'b'], ['c', 'd']]
    table_html=XML(TABLE(TR(*table[0]), TR(*table[1])))
    table_html=table_html.replace('</tr>','</tr>\n')
    response.write(table_html,escape=False)
    }}
    

    What is this doing?

    It serializes ( converts to a string ) the TABLE helper, uses the python string attribute replace() to insert the newlines, and finally uses the web2py function response.write() to output the modified string to the document.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am quite happy to code out tables by hand when making a database
I'm making a table with data, and the last column needs to be have
I have look-up-table as defined below and I'm making use of GCC. When I
Okay, so I'm making a table right now for Box Items. Now, a Box
What are the advantages and disadvantages of making a self-referencing table column a foreign
I have a question about tables in MySQL. I'm currently making a website where
I'm making table rows click-able with jQuery's $.live() function. Works perfectly on Chrome, Firefox
I am making a table in which you can add aditional rows. When you
I am making a table of data that needs to printed out. I want
I am making a table using QItemDelegate. I use the paint(..) method to draw

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.