bootstrap-flask icon indicating copy to clipboard operation
bootstrap-flask copied to clipboard

render_table and multiline

Open serensoner opened this issue 3 years ago • 3 comments

hey there, i'm using render table with a field that sometimes has multilines (separated by \n, or possibly <br />. is there a way to show this as multilines using render_table? i tried render_table(...)|safe and render_table(data, ..)|safe but neither worked. any ideas?

serensoner avatar Feb 13 '22 13:02 serensoner

I'm looking for something similar but to add e.g. <a href="https://blahblah.blah/?q=CELL%20CONTENT">CELL CONTENT</a> in a cell the would normally show CELL CONTENT. Would it fix our cases and other cases if we could pass a list of tuples with columns names and a macro to be called for each cell in that column for a table?

An example would be:

render_table(...., macros=[('Category', 'my_macro')])

with implementation (in pseudo code)

if title[1] in macros:
#    <td>{{ macros[title[1]](row[title[0]]) }}</td>
# which results in
    <td>{{ my_macro(row[title[0]]) }}</td>
else:
    <td>{{ row[title[0]] }}</td>

PanderMusubi avatar Feb 14 '22 16:02 PanderMusubi

@serensnoer, for you what would be using self() instead of my_macro().

PanderMusubi avatar Feb 14 '22 16:02 PanderMusubi

@serensoner see https://github.com/greyli/bootstrap-flask/pull/204 which offers safe for specific columns.

PanderMusubi avatar Feb 21 '22 21:02 PanderMusubi

Implemented in #204.

greyli avatar Aug 20 '22 10:08 greyli