Skip to content

Commit caaafa7

Browse files
committed
fix(template): allow whitespace in extends children
1 parent 53756cb commit caaafa7

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/Renderer.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#include <cstdlib>
2727
#include <utility>
2828
#include <variant>
29+
#include <cctype>
30+
#include <string_view>
2931

3032
namespace vix::template_
3133
{
@@ -61,6 +63,19 @@ namespace vix::template_
6163
return true;
6264
}
6365

66+
[[nodiscard]] bool is_whitespace_only(std::string_view text) noexcept
67+
{
68+
for (const unsigned char c : text)
69+
{
70+
if (!std::isspace(c))
71+
{
72+
return false;
73+
}
74+
}
75+
76+
return true;
77+
}
78+
6479
[[nodiscard]] bool is_floating_literal(const std::string &value) noexcept
6580
{
6681
if (value.empty())
@@ -848,6 +863,15 @@ namespace vix::template_
848863
continue;
849864
}
850865

866+
if (child->type() == NodeType::Text)
867+
{
868+
const auto &text = static_cast<const TextNode &>(*child);
869+
if (is_whitespace_only(text.value()))
870+
{
871+
continue;
872+
}
873+
}
874+
851875
if (child->type() != NodeType::Block)
852876
{
853877
throw RendererError(

0 commit comments

Comments
 (0)