23#include "../lib/exception.h"
24#include "filterexpression.h"
28FilterNodeFactory::FilterNodeFactory() {}
33#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
34 auto expr = tagContent.split(QLatin1Char(
' '), QString::SkipEmptyParts);
36 auto expr = tagContent.split(QLatin1Char(
' '), Qt::SkipEmptyParts);
41 auto expression = expr.join(QChar::fromLatin1(
' '));
44 auto filters = fe.filters();
45 if (filters.contains(QStringLiteral(
"safe"))
46 || filters.contains(QStringLiteral(
"escape"))) {
48 TagSyntaxError, QStringLiteral(
"Use the \"autoescape\" tag instead."));
53 auto filterNodes = p->
parse(n, QStringLiteral(
"endfilter"));
56 n->setNodeList(filterNodes);
61 :
Node(parent), m_fe(fe)
65void FilterNode::setNodeList(
const NodeList &filterList)
67 m_filterList = filterList;
73 QTextStream textStream(&output);
74 auto temp = stream->
clone(&textStream);
75 m_filterList.
render(temp.get(), c);
77 c->
insert(QStringLiteral(
"var"), output);
The Context class holds the context to render a Template with.
void insert(const QString &name, QObject *object)
An exception for use when implementing template tags.
A FilterExpression object represents a filter expression in a template.
QVariant resolve(OutputStream *stream, Context *c) const
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
Utility functions used throughout Cutelee.