Grantlee  0.4.0
Public Member Functions | Protected Member Functions
Grantlee::Node Class Reference

Base class for all nodes. More...

#include <grantlee/node.h>

List of all members.

Public Member Functions

 Node (QObject *parent=0)
virtual ~Node ()
virtual void render (OutputStream *stream, Context *c)=0

Protected Member Functions

TemplateImpl * containerTemplate () const
void streamValueInContext (OutputStream *stream, const QVariant &input, Grantlee::Context *c)

Detailed Description

The Node class can be implemented to make additional functionality available to Templates.

A node is represented in template markup as content surrounded by percent signed tokens.

    text content
    {% some_tag arg1 arg2 %}
      text content
    {% some_other_tag arg1 arg2 %}
      text content
    {% end_some_other_tag %}
    text content

This is parsed into a tree of Node objects by an implementation of AbstractNodeFactory. The Node objects can then later be rendered by their render method.

Rendering a Node will usually mean writing some output to the stream. The content written to the stream could be determined by the arguments to the tag, or by the content of child nodes between a start and end tag, or both.

See also:
FilterExpression
Tags
Author:
Stephen Kelly <steveire@gmail.com>

Definition at line 76 of file node.h.


Constructor & Destructor Documentation

Grantlee::Node::Node ( QObject *  parent = 0) [explicit]

Constructor.

Parameters:
parentThe parent QObject
virtual Grantlee::Node::~Node ( ) [virtual]

Destructor.


Member Function Documentation

TemplateImpl* Grantlee::Node::containerTemplate ( ) const [protected]

Returns a raw pointer to the Template this Node is in.

virtual void Grantlee::Node::render ( OutputStream stream,
Context c 
) [pure virtual]

Reimplement this to render the template in the Context c.

This will also involve calling render on and child nodes.

void Grantlee::Node::streamValueInContext ( OutputStream stream,
const QVariant &  input,
Grantlee::Context c 
) [protected]

Renders the value input in the Context c. This will involve escaping input if necessary.

This is only relevant to developing template tags.