21 #include "filtertag.h" 23 #include "../lib/exception.h" 24 #include "filterexpression.h" 28 FilterNodeFactory::FilterNodeFactory() {}
40 auto filters = fe.filters();
41 if (filters.contains(QStringLiteral(
"safe"))
42 || filters.contains(QStringLiteral(
"escape"))) {
44 TagSyntaxError, QStringLiteral(
"Use the \"autoescape\" tag instead."));
49 auto filterNodes = p->
parse(n, QStringLiteral(
"endfilter"));
52 n->setNodeList(filterNodes);
57 :
Node(parent), m_fe(fe)
61 void FilterNode::setNodeList(
const NodeList &filterList)
63 m_filterList = filterList;
70 auto temp = stream->
clone(&textStream);
71 m_filterList.
render(temp.get(), c);
73 c->
insert(QStringLiteral(
"var"), output);
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
QVariant resolve(OutputStream *stream, Context *c) const
The Parser class processes a string template into a tree of nodes.
A list of Nodes with some convenience API for rendering them.
virtual std::shared_ptr< OutputStream > clone(QTextStream *stream) const
A FilterExpression object represents a filter expression in a template.
void render(OutputStream *stream, Context *c) const override
Node * getNode(const QString &tagContent, Parser *p) const override
void insert(const QString &name, QObject *object)
void render(OutputStream *stream, Context *c) const
An exception for use when implementing template tags.