From e1dd9c59a0112a3d1a3925b4f6dae727f659464b Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 27 Dec 2020 22:38:31 +0100 Subject: [PATCH] Added charset helper itno HTMLTag. --- core/html_builder.cpp | 12 ++++++++++++ core/html_builder.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/core/html_builder.cpp b/core/html_builder.cpp index cf4d343..44dc57d 100644 --- a/core/html_builder.cpp +++ b/core/html_builder.cpp @@ -58,6 +58,18 @@ HTMLTag *HTMLTag::rel_stylesheet() { return this; } +HTMLTag *HTMLTag::charset(const std::string &val) { + attrib("charset", val); + + return this; +} + +HTMLTag *HTMLTag::charset_utf_8() { + attrib("charset", "utf-8"); + + return this; +} + HTMLTag *HTMLTag::attrib(const std::string &attr, const std::string &val) { result += " " + attr + "=\"" + val + "\""; diff --git a/core/html_builder.h b/core/html_builder.h index cb3ea5a..11286d0 100644 --- a/core/html_builder.h +++ b/core/html_builder.h @@ -24,6 +24,8 @@ public: HTMLTag *type(const std::string &val); HTMLTag *rel(const std::string &val); HTMLTag *rel_stylesheet(); + HTMLTag *charset(const std::string &val); + HTMLTag *charset_utf_8(); HTMLTag *attrib(const std::string &attr, const std::string &val);