21 #include "autoescape.h" 23 #include "exception.h" 28 #include <QtCore/QFile> 30 AutoescapeNodeFactory::AutoescapeNodeFactory() {}
35 if (expr.size() != 2) {
37 TagSyntaxError, QStringLiteral(
"autoescape takes two arguments."));
40 auto strState = expr.at(1);
42 if (strState == QStringLiteral(
"on"))
43 state = AutoescapeNode::On;
44 else if (strState == QStringLiteral(
"off"))
45 state = AutoescapeNode::Off;
48 QStringLiteral(
"argument must be 'on' or 'off'"));
53 auto list = p->
parse(n, QStringLiteral(
"endautoescape"));
61 AutoescapeNode::AutoescapeNode(
int state,
QObject *parent)
62 :
Node(parent), m_state(state)
66 void AutoescapeNode::setList(
const NodeList &list) { m_list = list; }
70 const auto old_setting = c->autoEscape();
71 c->setAutoEscape(m_state == On);
73 c->setAutoEscape(old_setting);
NodeList parse(Node *parent, const QStringList &stopAt={})
The Context class holds the context to render a Template with.
Base class for all nodes.
Utility functions used throughout Cutelee.
The OutputStream class is used to render templates to a QTextStream.
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
The Parser class processes a string template into a tree of nodes.
Node * getNode(const QString &tagContent, Parser *p) const override
A list of Nodes with some convenience API for rendering them.
void render(OutputStream *stream, Context *c) const override
void render(OutputStream *stream, Context *c) const
An exception for use when implementing template tags.