From 7e4c5eeb3eaca857a4516db97f6bed70b4d76bde Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 16 Nov 2021 16:51:02 +0100 Subject: [PATCH] Added 2 more helpers to HTMLBuilder. --- core/html/html_builder.cpp | 24 ++++++++++++++++++++++++ core/html/html_builder.h | 3 +++ 2 files changed, 27 insertions(+) diff --git a/core/html/html_builder.cpp b/core/html/html_builder.cpp index 6207e81..670704f 100644 --- a/core/html/html_builder.cpp +++ b/core/html/html_builder.cpp @@ -1500,6 +1500,30 @@ HTMLTag *HTMLBuilder::wbr() { return tag.start("wbr"); } +HTMLTag *HTMLBuilder::a(const String &href, const String &cls, const String &id) { + HTMLTag *t = input_text(); + + t->href(href); + + if (cls != "") { + t->cls(cls); + } + + if (id != "") { + t->id(id); + } + + return t; +} + +HTMLBuilder *HTMLBuilder::fa(const String &href, const String &body, const String &cls, const String &id) { + a(href, cls, id); + w(body); + ca(); + + return this; +} + //Closing tags HTMLBuilder *HTMLBuilder::ca() { diff --git a/core/html/html_builder.h b/core/html/html_builder.h index c9dffa3..d218ea0 100644 --- a/core/html/html_builder.h +++ b/core/html/html_builder.h @@ -304,6 +304,9 @@ public: HTMLTag *video(); HTMLTag *wbr(); + HTMLTag *a(const String& href, const String& cls = "", const String& id = ""); + HTMLBuilder *fa(const String& href, const String& body, const String& cls = "", const String& id = ""); + //closing tags c prefix means close //Note simple tags should not have these like
//Note that I might have a few that shouldn't be here, those will be removed as I find them