hemplate

Simple XML template engine
git clone git://git.dimitrijedobrota.com/hemplate.git
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING

commit bf0259c773f61a6115772fba2154b3ee143640d9
parent 00a13505aef2305ac56e010013b731e3d026ad21
author Dimitrije Dobrota <mail@dimitrijedobrota.com>
date Thu, 9 Jan 2025 19:12:35 +0100

Empty tag(text), and general cleanup

Diffstat:
M .clang-tidy | +
M CMakeLists.txt | + -
M include/hemplate/classes.hpp | +++++++ ----
M include/hemplate/element.hpp | ++ --
M source/attribute.cpp | ++ -
M source/element.cpp | +++++++++++
M test/source/hemplate_test.cpp | +

7 files changed, 25 insertions(+), 8 deletions(-)


diff --git a/ .clang-tidy b/ .clang-tidy

@@ -19,6 +19,7 @@ Checks: "*,\ -readability-magic-numbers,\ fuchsia-multiple-inheritance,\ -misc-no-recursion,\
-performance-avoid-endl,\
-misc-non-private-member-variables-in-classes" WarningsAsErrors: '' CheckOptions:

diff --git a/ CMakeLists.txt b/ CMakeLists.txt

@@ -4,7 +4,7 @@ include(cmake/prelude.cmake) project( hemplate
VERSION 0.1.10
VERSION 0.1.11
DESCRIPTION "Simple HTML template engine" HOMEPAGE_URL "https://git.dimitrijedobrota.com/hemplate.git" LANGUAGES CXX

diff --git a/ include/hemplate/classes.hpp b/ include/hemplate/classes.hpp

@@ -179,6 +179,7 @@ using table = elementBoolean<tag<"table">>; using tbody = elementBoolean<tag<"tbody">>; using td = elementBoolean<tag<"td">>; using textarea = elementBoolean<tag<"textarea">>;
using text = elementBoolean<tag<"">>;
using tfoot = elementBoolean<tag<"tfoot">>; using th = elementBoolean<tag<"th">>; using thead = elementBoolean<tag<"thead">>;

@@ -201,8 +202,8 @@ class rss : public elementBoolean<tag<"rss">> public: explicit rss(std::string version = "2.0", std::string xmlns = "http://www.w3.org/2005/Atom")
: elementBoolean(attributeList(
{{"version", std::move(version)}, {"xmlns:atom", std::move(xmlns)}}))
: elementBoolean(attributeList({{"version", std::move(version)},
{"xmlns:atom", std::move(xmlns)}}))
{ } };

@@ -212,8 +213,8 @@ class atomLink : public elementAtomic<tag<"atom:link">> public: explicit atomLink(std::string rel = "self", std::string type = "application/rss+xml")
: elementAtomic(
attributeList({{"rel", std::move(rel)}, {"type", std::move(type)}}))
: elementAtomic(attributeList(
{{"rel", std::move(rel)}, {"type", std::move(type)}}))
{ } };

@@ -242,6 +243,7 @@ using rating = elementBoolean<tag<"rating">>; using skipDays = elementBoolean<tag<"skipDays">>; using skipHours = elementBoolean<tag<"skipHours">>; using source = elementBoolean<tag<"source">>;
using text = elementBoolean<tag<"">>;
using textinput = elementBoolean<tag<"textinput">>; using title = elementBoolean<tag<"title">>; using ttl = elementBoolean<tag<"ttl">>;

@@ -282,6 +284,7 @@ using rights = elementBoolean<tag<"rights">>; using source = elementBoolean<tag<"source">>; using subtitle = elementBoolean<tag<"subtitle">>; using summary = elementBoolean<tag<"summary">>;
using text = elementBoolean<tag<"">>;
using title = elementBoolean<tag<"title">>; using update = elementBoolean<tag<"update">>; using updated = elementBoolean<tag<"updated">>;

diff --git a/ include/hemplate/element.hpp b/ include/hemplate/element.hpp

@@ -23,7 +23,7 @@ public: template<class... Ts> explicit elementList(Ts&&... args) {
std::initializer_list<element*> list = {&args...};
std::initializer_list<element*> list = {&std::forward(args)...};
for (const auto& elem : list) add(*elem); }

@@ -45,7 +45,7 @@ private: class HEMPLATE_EXPORT element : public streamable { public:
enum class Type
enum class Type : uint8_t
{ Atomic, Boolean,

diff --git a/ source/attribute.cpp b/ source/attribute.cpp

@@ -1,4 +1,5 @@
#include <algorithm>
#include <initializer_list>
#include <ostream>
#include "hemplate/attribute.hpp"

diff --git a/ source/element.cpp b/ source/element.cpp

@@ -1,3 +1,8 @@
#include <memory>
#include <ostream>
#include <string>
#include <utility>
#include "hemplate/element.hpp" namespace hemplate {

@@ -28,6 +33,12 @@ element& element::set(const std::string& name, const std::string& value) void element::render(std::ostream& out) const {
if (*get_name() == '\0')
{
out << m_data;
return;
}
const auto open_tag = [this, &out](bool atomic) { out << '<' << get_name();

diff --git a/ test/source/hemplate_test.cpp b/ test/source/hemplate_test.cpp

@@ -1,6 +1,7 @@ #include <iostream> #include "hemplate/classes.hpp"
#include "hemplate/attribute.hpp"
int main() {