FactDev
0.1
|
#include <mustache.h>
Public Member Functions | |
Context (PartialResolver *resolver=0) | |
virtual QString | stringValue (const QString &key) const =0 |
virtual bool | isFalse (const QString &key) const =0 |
virtual int | listCount (const QString &key) const =0 |
virtual void | push (const QString &key, int index=-1)=0 |
virtual void | pop ()=0 |
QString | partialValue (const QString &key) const |
PartialResolver * | partialResolver () const |
virtual bool | canEval (const QString &key) const |
virtual QString | eval (const QString &key, const QString &_template, Renderer *renderer) |
Context is an interface that Mustache::Renderer::render() uses to fetch substitutions for template tags.
|
explicit |
Create a context. resolver
is used to fetch the expansions for any {{>partial}} tags which appear in a template.
|
virtual |
Returns true if eval() should be used to render section tags using key
. If canEval() returns true for a key, the renderer will pass the literal, unrendered block of text for the section to eval() and replace the section with the result.
canEval() and eval() are equivalents for callable objects (eg. lambdas) in other Mustache implementations.
The default implementation always returns false.
Reimplemented in CounterContext, CounterContext, and Mustache::QtVariantContext.
|
virtual |
Callback used to render a template section with the given key
. renderer
will substitute the original section tag with the result of eval().
The default implementation returns an empty string.
Reimplemented in CounterContext, CounterContext, and Mustache::QtVariantContext.
|
pure virtual |
Returns true if the value for key
is 'false' or an empty list. 'False' values typically include empty strings, the boolean value false etc.
When processing a section Mustache tag, the section is not rendered if the key is false, or for an inverted section tag, the section is only rendered if the key is false.
Implemented in Mustache::QtVariantContext.
|
pure virtual |
Returns the number of items in the list value for key
or 0 if the value for key
is not a list.
Implemented in Mustache::QtVariantContext.
PartialResolver * Context::partialResolver | ( | ) | const |
Returns the partial resolver passed to the constructor.
QString Context::partialValue | ( | const QString & | key | ) | const |
Returns the partial template for a given key
.
|
pure virtual |
Exit the current context.
Implemented in Mustache::QtVariantContext.
|
pure virtual |
Set the current context to the value for key
. If index is >= 0, set the current context to the index'th
value in the list value for key
.
Implemented in Mustache::QtVariantContext.
|
pure virtual |
Returns a string representation of the value for key
in the current context. This is used to replace a Mustache value tag.
Implemented in CounterContext, CounterContext, and Mustache::QtVariantContext.