Added new helper methods to HTMLBuilder.

This commit is contained in:
Relintai 2021-11-02 12:26:46 +01:00
parent 7fcd38fff7
commit 80c3b97a6b
2 changed files with 26 additions and 0 deletions

View File

@ -48,6 +48,14 @@ HTMLTag *HTMLTag::value(const String &val) {
return this;
}
HTMLTag *HTMLTag::checked(const bool val) {
if (val) {
result += " checked";
}
return this;
}
HTMLTag *HTMLTag::method(const String &val) {
attrib("method", val);
@ -1773,6 +1781,21 @@ HTMLBuilder *HTMLBuilder::wui(const uint64_t val, const int base, const bool cap
return this;
}
HTMLBuilder *HTMLBuilder::wbn(const bool val) {
write_tag();
result += String::bool_num(val);
return this;
}
HTMLBuilder *HTMLBuilder::wbs(const bool val) {
write_tag();
result += String::bool_str(val);
return this;
}
//TODO!
HTMLBuilder *HTMLBuilder::we(const String &val) {
printf("HTMLBuilder::write_excaped NYI!");

View File

@ -19,6 +19,7 @@ public:
HTMLTag *name(const String &val);
HTMLTag *content(const String &val);
HTMLTag *value(const String &val);
HTMLTag *checked(const bool val = true);
HTMLTag *method(const String &val);
HTMLTag *action(const String &val);
HTMLTag *type(const String &val);
@ -317,6 +318,8 @@ public:
HTMLBuilder *wr(const double val, const bool p_trailing = true);
HTMLBuilder *wi(const int64_t val, const int base = 10, const bool capitalize_hex = false);
HTMLBuilder *wui(const uint64_t val, const int base = 10, const bool capitalize_hex = false);
HTMLBuilder *wbn(const bool val);
HTMLBuilder *wbs(const bool val);
//write_escaped
HTMLBuilder *we(const String &val);