17 #include <QtCore/QStack>
18 #include <QtCore/QString>
19 #include <QtCore/QVariant>
21 #if __cplusplus >= 201103L
28 class PartialResolver;
46 virtual QString
stringValue(
const QString& key)
const = 0;
55 virtual bool isFalse(
const QString& key)
const = 0;
60 virtual int listCount(
const QString& key)
const = 0;
66 virtual void push(
const QString& key,
int index = -1) = 0;
69 virtual void pop() = 0;
86 virtual bool canEval(
const QString& key)
const;
93 virtual QString
eval(
const QString& key,
const QString& _template,
Renderer* renderer);
106 #if __cplusplus >= 201103L
107 typedef std::function<QString(const QString&, Mustache::Renderer*, Mustache::Context*)>
fn_t;
113 virtual QString
stringValue(
const QString& key)
const;
114 virtual bool isFalse(
const QString& key)
const;
115 virtual int listCount(
const QString& key)
const;
116 virtual void push(
const QString& key,
int index = -1);
118 virtual bool canEval(
const QString& key)
const;
122 QVariant value(
const QString& key)
const;
124 QStack<QVariant> m_contextStack;
134 virtual QString
getPartial(
const QString& name) = 0;
142 explicit PartialMap(
const QHash<QString,QString>& partials);
144 virtual QString
getPartial(
const QString& name);
147 QHash<QString, QString> m_partials;
160 virtual QString
getPartial(
const QString& name);
164 QHash<QString, QString> m_cache;
200 EscapeMode escapeMode;
219 QString
error()
const;
237 void setTagMarkers(
const QString& startMarker,
const QString& endMarker);
240 QString
render(
const QString& _template,
int startPos,
int endPos,
Context* context);
242 Tag findTag(
const QString& content,
int pos,
int endPos);
243 Tag findEndTag(
const QString& content,
const Tag& startTag,
int endPos);
244 void setError(
const QString& error,
int pos);
246 void readSetDelimiter(
const QString& content,
int pos,
int endPos);
247 static QString readTagName(
const QString& content,
int pos,
int endPos);
257 static void expandTag(
Tag& tag,
const QString& content);
259 QStack<QString> m_partialStack;
262 QString m_errorPartial;
264 QString m_tagStartMarker;
265 QString m_tagEndMarker;
267 QString m_defaultTagStartMarker;
268 QString m_defaultTagEndMarker;
272 QString renderTemplate(
const QString& templateString,
const QVariantHash& args);
Definition: mustache.h:100
virtual QString getPartial(const QString &name)
Definition: mustache.cpp:214
virtual QString getPartial(const QString &name)
Definition: mustache.cpp:205
Context(PartialResolver *resolver=0)
Definition: mustache.cpp:66
QString(* fn_t)(const QString &, Mustache::Renderer *, Mustache::Context *)
Definition: mustache.h:109
QString errorPartial() const
Definition: mustache.cpp:244
virtual QString eval(const QString &key, const QString &_template, Renderer *renderer)
Definition: mustache.cpp:88
void setTagMarkers(const QString &startMarker, const QString &endMarker)
Definition: mustache.cpp:520
virtual bool isFalse(const QString &key) const =0
virtual int listCount(const QString &key) const
Definition: mustache.cpp:179
virtual bool isFalse(const QString &key) const
Definition: mustache.cpp:138
Definition: mustache.h:139
virtual QString eval(const QString &key, const QString &_template, Mustache::Renderer *renderer)
Definition: mustache.cpp:192
Definition: mustache.h:155
virtual bool canEval(const QString &key) const
Definition: mustache.cpp:187
Definition: mustache.h:34
A {{/section}} tag.
Definition: mustache.h:177
QString partialValue(const QString &key) const
Definition: mustache.cpp:75
virtual void push(const QString &key, int index=-1)=0
QString render(const QString &_template, Context *context)
Definition: mustache.cpp:249
virtual QString stringValue(const QString &key) const
Definition: mustache.cpp:155
virtual void pop()
Definition: mustache.cpp:174
Definition: mustache.h:206
virtual int listCount(const QString &key) const =0
QString error() const
Definition: mustache.cpp:234
An {{^inverted-section}} tag.
Definition: mustache.h:176
Definition: mustache.h:128
Definition: mustache.h:168
A {{#section}} tag.
Definition: mustache.h:175
A {{^partial}} tag.
Definition: mustache.h:178
virtual void push(const QString &key, int index=-1)
Definition: mustache.cpp:163
A {{key}} or {{{key}}} tag.
Definition: mustache.h:174
A {{! comment }} tag.
Definition: mustache.h:179
int errorPos() const
Definition: mustache.cpp:239
virtual QString getPartial(const QString &name)=0
virtual QString stringValue(const QString &key) const =0
virtual bool canEval(const QString &key) const
Definition: mustache.cpp:83
Type
Definition: mustache.h:170
PartialResolver * partialResolver() const
Definition: mustache.cpp:70