33 lines
1.2 KiB
C++
33 lines
1.2 KiB
C++
#include <format>
|
|
#include "HtmxShAttributeList.hpp"
|
|
#include "utils.hpp"
|
|
|
|
using namespace std;
|
|
|
|
HtmxShAttributeList::HtmxShAttributeList(const std::string& id, const vector<string>& itemList){
|
|
html += format("<h2>{}</h2>", id);
|
|
html += "<div class='grid'>";
|
|
for (auto& item : itemList){
|
|
string item_id = utils::to_id_format(format("{}_{}", id, item));
|
|
|
|
html += format("<label>{}:<input type='text' name='{}'></label>", item, item_id);
|
|
}
|
|
html += "</div>";
|
|
}
|
|
|
|
HtmxShAttributeList::HtmxShAttributeList(const std::string& id, const std::vector<std::pair<std::string, std::string>>& itemValueList){
|
|
html += format("<h2>{}</h2>", id);
|
|
html += "<div class='grid'>";
|
|
for (auto& item : itemValueList){
|
|
string item_id = utils::to_id_format(format("{}_{}", id, item));
|
|
html += format("<label>{}:<input type='text' name='{}' value='{}'></label>", item, item_id, item.second);
|
|
}
|
|
html += "</div>";
|
|
}
|
|
|
|
void HtmxShAttributeList::genIds(std::vector<std::string>& vec, const std::string& id, const std::vector<std::string>& itemList)
|
|
{
|
|
for (auto& item : itemList){
|
|
vec.push_back(utils::to_id_format(format("{}_{}", id, item)));
|
|
}
|
|
} |