On Fri, 17 Mar 2017 20:59:28 +0100, Sönke Ludwig wrote:
Am 14.03.2017 um 17:28 schrieb Carl Sturtivant:
Would like a clean way to include different table tags depending upon a condition. But there's a snag. I can work around it, but wondering if there's a clean solution.
- if( condition) table(...) - else table(....) tr th .....
The indentation of
tr
is necessary for it to be inside the table, but that indentation stops theelse
branch from ending. So the table body is not included when the condition is true. How do I end theif
keeping the indentation oftr
in an elegant way?The best you can probably do is to use a function or an include:
- void tableContent() tr th ... - if (condition) table(...) - tableContent(); - else table(...) - tableContent();
When I use this technique with pretty printed HTML I find that indentation goes wrong.
Specifically the HTML produced by the function call is not indented one more step and the first tag from that call is placed on the same line as the tag preceding it in the branch.