FactDev  0.1
Mustache::QtVariantContext Class Reference

#include <mustache.h>

Inheritance diagram for Mustache::QtVariantContext:
Mustache::Context CounterContext CounterContext

Public Types

typedef QString(* fn_t )(const QString &, Mustache::Renderer *, Mustache::Context *)
 

Public Member Functions

 QtVariantContext (const QVariant &root, PartialResolver *resolver=0)
 
virtual QString stringValue (const QString &key) const
 
virtual bool isFalse (const QString &key) const
 
virtual int listCount (const QString &key) const
 
virtual void push (const QString &key, int index=-1)
 
virtual void pop ()
 
virtual bool canEval (const QString &key) const
 
virtual QString eval (const QString &key, const QString &_template, Mustache::Renderer *renderer)
 
- Public Member Functions inherited from Mustache::Context
 Context (PartialResolver *resolver=0)
 
QString partialValue (const QString &key) const
 
PartialResolverpartialResolver () const
 

Detailed Description

A context implementation which wraps a QVariantHash or QVariantMap.

Member Typedef Documentation

typedef QString(* Mustache::QtVariantContext::fn_t)(const QString &, Mustache::Renderer *, Mustache::Context *)

Construct a QtVariantContext which wraps a dictionary in a QVariantHash or a QVariantMap.

Member Function Documentation

bool QtVariantContext::canEval ( const QString &  key) const
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 from Mustache::Context.

Reimplemented in CounterContext, and CounterContext.

QString QtVariantContext::eval ( const QString &  key,
const QString &  _template,
Mustache::Renderer renderer 
)
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 from Mustache::Context.

Reimplemented in CounterContext, and CounterContext.

bool QtVariantContext::isFalse ( const QString &  key) const
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.

Implements Mustache::Context.

int QtVariantContext::listCount ( const QString &  key) const
virtual

Returns the number of items in the list value for key or 0 if the value for key is not a list.

Implements Mustache::Context.

void QtVariantContext::pop ( )
virtual

Exit the current context.

Implements Mustache::Context.

void QtVariantContext::push ( const QString &  key,
int  index = -1 
)
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.

Implements Mustache::Context.

QString QtVariantContext::stringValue ( const QString &  key) const
virtual

Returns a string representation of the value for key in the current context. This is used to replace a Mustache value tag.

Implements Mustache::Context.

Reimplemented in CounterContext, and CounterContext.


The documentation for this class was generated from the following files: