21 #include "autoescape.h"
23 #include "exception.h"
28 #include <QtCore/QFile>
30 AutoescapeNodeFactory::AutoescapeNodeFactory() {}
34 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
35 auto expr = tagContent.split(QLatin1Char(
' '), QString::SkipEmptyParts);
37 auto expr = tagContent.split(QLatin1Char(
' '), Qt::SkipEmptyParts);
40 if (expr.size() != 2) {
42 TagSyntaxError, QStringLiteral(
"autoescape takes two arguments."));
45 auto strState = expr.at(1);
47 if (strState == QStringLiteral(
"on"))
48 state = AutoescapeNode::On;
49 else if (strState == QStringLiteral(
"off"))
50 state = AutoescapeNode::Off;
53 QStringLiteral(
"argument must be 'on' or 'off'"));
58 auto list = p->
parse(n, QStringLiteral(
"endautoescape"));
66 AutoescapeNode::AutoescapeNode(
int state, QObject *parent)
67 :
Node(parent), m_state(state)
71 void AutoescapeNode::setList(
const NodeList &list) { m_list = list; }
75 const auto old_setting = c->autoEscape();
76 c->setAutoEscape(m_state == On);
78 c->setAutoEscape(old_setting);
Node * getNode(const QString &tagContent, Parser *p) const override
void render(OutputStream *stream, Context *c) const override
The Context class holds the context to render a Template with.
An exception for use when implementing template tags.
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.
The Parser class processes a string template into a tree of nodes.
NodeList parse(Node *parent, const QStringList &stopAt={})
Utility functions used throughout Cutelee.