Skip to content

Commit

Permalink
db-tabulator: further header_template fixes
Browse files Browse the repository at this point in the history
!restart
  • Loading branch information
siddharthvp committed Nov 27, 2023
1 parent 8f362f5 commit 1761a68
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions db-tabulator/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ export class Query {

let table: InstanceType<typeof Mwn.table>;
let tableText = '';

// NOTE: header_template appears:
// - above table start if row_template is not being used
// - below table start if row_template is being used
Expand All @@ -490,11 +491,16 @@ export class Query {
}
return columnConfig;
}));
tableText += table.text;
}
}

if (row_template) {
if (!skip_table && !header_template) {
// Add table top structure.
// Not applicable if skip_table is used.
// If header_template is there, tableText already include table top structure by now.
tableText += table.text;
}
for (let row of result) {
tableText += '{{' + row_template + Object.values(row).map((val, idx) => `|${idx + 1}=` + val).join('') + '}}\n';
}
Expand All @@ -509,9 +515,7 @@ export class Query {
for (let row of result) {
table.addRow(Object.values(row));
}
tableText = TextExtractor.finalSanitise(table.getText());
// XXX: header gets skipped if header_template is used without row_template,
// but module does show a warning
tableText += TextExtractor.finalSanitise(table.getText());
}

if (skip_table && footer_template) {
Expand Down

0 comments on commit 1761a68

Please sign in to comment.