24#include "../lib/exception.h"
27IfNodeFactory::IfNodeFactory() {}
33 std::vector<std::pair<std::shared_ptr<IfToken>,
NodeList>> nodelistConditions;
38 auto cond = ip.parse();
39 auto nodelist = p->
parse(n, {QStringLiteral(
"elif"), QStringLiteral(
"else"),
40 QStringLiteral(
"endif")});
41 nodelistConditions.
push_back({cond, nodelist});
50 nodelist = p->
parse(n, {QStringLiteral(
"elif"), QStringLiteral(
"else"),
51 QStringLiteral(
"endif")});
52 nodelistConditions.
push_back({cond, nodelist});
57 nodelist = p->
parse(n, QStringLiteral(
"endif"));
58 nodelistConditions.
push_back({
nullptr, nodelist});
62 n->setNodelistConditions(nodelistConditions);
64 auto commandName = expr.takeAt(0);
65 if (expr.size() <= 0) {
68 QStringLiteral(
"'%1' statement requires at least one argument")
77void IfNode::setNodelistConditions(
78 const std::vector<std::pair<std::shared_ptr<IfToken>,
NodeList>> &conditionNodelists)
80 mConditionNodelists = conditionNodelists;
88 for (
const auto &pair : mConditionNodelists) {
99 pair.second.render(stream, c);
Q_INVOKABLE QStringList smartSplit(const QString &str) const
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.
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={})
Node * getNode(const QString &tagContent, Parser *p) const override
void render(OutputStream *stream, Context *c) const override
bool variantIsTrue(const QVariant &variant)
void push_back(const T &value)