FactDev  0.1
Mustache::Context Class Referenceabstract

#include <mustache.h>

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

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
 
PartialResolverpartialResolver () const
 
virtual bool canEval (const QString &key) const
 
virtual QString eval (const QString &key, const QString &_template, Renderer *renderer)
 

Detailed Description

Context is an interface that Mustache::Renderer::render() uses to fetch substitutions for template tags.

Constructor & Destructor Documentation

Context::Context ( PartialResolver resolver = 0)
explicit

Create a context. resolver is used to fetch the expansions for any {{>partial}} tags which appear in a template.

Member Function Documentation

bool Context::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 in CounterContext, CounterContext, and Mustache::QtVariantContext.

QString Context::eval ( const QString &  key,
const QString &  _template,
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 in CounterContext, CounterContext, and Mustache::QtVariantContext.

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

virtual int Mustache::Context::listCount ( const QString &  key) const
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.

virtual void Mustache::Context::pop ( )
pure virtual

Exit the current context.

Implemented in Mustache::QtVariantContext.

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

virtual QString Mustache::Context::stringValue ( const QString &  key) const
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.


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