Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

html::writeRowInto(): don't write by default if value isFailed #17

Merged
merged 1 commit into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/og3/html_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ namespace og3::html {

void escape(String* out_str, const char* in_str);

void writeRowInto(String* out_str, const VariableBase& var, const char* name = nullptr);
void writeRowInto(String* out_str, const VariableBase& var, const char* name = nullptr,
bool write_even_if_failed = false);

void writeRowsInto(String* out_str, const VariableGroup& vars);
void writeTableInto(String* out_str, const VariableGroup& vars, const char* title = nullptr,
Expand Down
8 changes: 6 additions & 2 deletions src/html_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ void escape(String* out_str, const char* in_str) {
}
}

void writeRowInto(String* out_str, const VariableBase& var, const char* name) {
void writeRowInto(String* out_str, const VariableBase& var, const char* name,
bool write_even_if_failed) {
if (!write_even_if_failed && var.failed()) {
return;
}
*out_str += "<tr><td>";
escape(out_str, name ? name : var.human_str());
*out_str += "</td><td>";
Expand All @@ -48,7 +52,7 @@ void writeRowInto(String* out_str, const VariableBase& var, const char* name) {

void writeRowsInto(String* out_str, const VariableGroup& vars) {
for (const VariableBase* var : vars.variables()) {
if (!var->noDisplay() && !var->failed()) {
if (!var->noDisplay()) {
writeRowInto(out_str, *var);
}
}
Expand Down
Loading