41 lines
800 B
C++

//
// Created by lukas on 5/11/25.
//
#ifndef HTMXTABLE_H
#define HTMXTABLE_H
#include "HtmxObject.h"
#include "HtmxTableRow.h"
#include "format"
class HtmxTable : public HtmxObject {
public:
template<std::ranges::input_range R>
requires std::convertible_to<std::ranges::range_value_t<R>, std::string_view>
HtmxTable(const R& strings) {
// define the table header
html = "<table><tr>";
for (const auto& s : strings) {
html += format("<th>{}</th>", s);
}
html += "</tr>";
}
/**
* Add a htmx row to the table
*
* @param row
* @return htmx representation of the row
*/
void add_row(const HtmxTableRow& row);
/**
* Complete the table
*/
void complete();
};
#endif //HTMXTABLE_H