21 #include "spaceless.h"
23 #include <QtCore/QRegularExpression>
28 SpacelessNodeFactory::SpacelessNodeFactory() {}
34 auto list = p->
parse(n, QStringLiteral(
"endspaceless"));
40 SpacelessNode::SpacelessNode(QObject *parent) :
Node(parent) {}
42 void SpacelessNode::setList(
const NodeList &nodeList) { m_nodeList = nodeList; }
44 QString SpacelessNode::stripSpacesBetweenTags(
const QString &input)
46 auto stripped = input;
48 static const QRegularExpression re(QStringLiteral(
">\\s+<"));
49 stripped.replace(re, QStringLiteral(
"><"));
56 QTextStream textStream(&output);
57 auto temp = stream->
clone(&textStream);
58 m_nodeList.
render(temp.get(), c);
59 (*stream) <<
markSafe(stripSpacesBetweenTags(output.trimmed()));
The Context class holds the context to render a Template with.
A list of Nodes with some convenience API for rendering them.
void render(OutputStream *stream, Context *c) const
Base class for all nodes.
The OutputStream class is used to render templates to a QTextStream.
virtual std::shared_ptr< OutputStream > clone(QTextStream *stream) const
The Parser class processes a string template into a tree of nodes.
NodeList parse(Node *parent, const QStringList &stopAt={})
Node * getNode(const QString &tagContent, Parser *p) const override
void render(OutputStream *stream, Context *c) const override
Cutelee::SafeString markSafe(const Cutelee::SafeString &input)
Utility functions used throughout Cutelee.