Also added tag() and ctag() helpers to the c++ side HTMLBuilder, and smaller cleanups.

This commit is contained in:
Relintai 2022-12-18 16:53:23 +01:00
parent f9ef920ec5
commit 7eed422442
3 changed files with 180 additions and 161 deletions

File diff suppressed because it is too large Load Diff

View File

@ -28,7 +28,7 @@ public:
HTMLTag *alt(const String &val);
HTMLTag *inputmode(const String &val);
HTMLTag *list(const String &val);
HTMLTag *rows(const String &val);
HTMLTag *cols(const String &val);
@ -532,6 +532,9 @@ public:
HTMLBuilder *csrf_token(const String &token);
HTMLBuilder *csrf_tokenr(Ref<WebServerRequest> request);
HTMLTag *tag(const String &p_tag, const bool p_simple = false);
HTMLBuilder *ctag(const String &p_tag);
void f();
// write
@ -554,7 +557,7 @@ public:
virtual ~HTMLBuilder();
protected:
HTMLTag tag;
HTMLTag _tag;
};
#endif

View File

@ -858,10 +858,10 @@ Ref<_HTMLTag> _HTMLTag::attrib(const String &attr, const String &val) {
return Ref<_HTMLTag>(this);
}
Ref<_HTMLTag> _HTMLTag::start(const String &p__tag, const bool p_simple) {
Ref<_HTMLTag> _HTMLTag::start(const String &p_tag, const bool p_simple) {
simple = p_simple;
result = "<" + p__tag;
result = "<" + p_tag;
return Ref<_HTMLTag>(this);
}
@ -3519,16 +3519,16 @@ Ref<_HTMLBuilder> _HTMLBuilder::csrf_tokenr(Ref<WebServerRequest> request) {
return csrf_token(request->get_csrf_token());
}
Ref<_HTMLTag> _HTMLBuilder::tag(const String &p__tag, const bool p_simple) {
Ref<_HTMLTag> _HTMLBuilder::tag(const String &p_tag, const bool p_simple) {
write_tag();
return _tag->start(p__tag, p_simple);
return _tag->start(p_tag, p_simple);
}
Ref<_HTMLBuilder> _HTMLBuilder::ctag(const String &p__tag) {
Ref<_HTMLBuilder> _HTMLBuilder::ctag(const String &p_tag) {
write_tag();
result += "</";
result += p__tag;
result += p_tag;
result += ">";
return Ref<_HTMLBuilder>(this);