My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
TemplateNodeBlock Class Reference

Class representing a 'block' tag in a template. More...

Inheritance diagram for TemplateNodeBlock:
TemplateNodeCreator< TemplateNodeBlock > TemplateNode

Public Member Functions

 TemplateNodeBlock (TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
 
void render (FTextStream &ts, TemplateContext *c)
 
QCString name () const
 
- Public Member Functions inherited from TemplateNodeCreator< TemplateNodeBlock >
 TemplateNodeCreator (TemplateParser *parser, TemplateNode *parent, int line)
 
TemplateImplgetTemplate ()
 
- Public Member Functions inherited from TemplateNode
 TemplateNode (TemplateNode *parent)
 
virtual ~TemplateNode ()
 
TemplateNodeparent ()
 

Private Attributes

QCString m_blockName
 
TemplateNodeList m_nodes
 

Additional Inherited Members

- Static Public Member Functions inherited from TemplateNodeCreator< TemplateNodeBlock >
static TemplateNodecreateInstance (TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
 
- Protected Member Functions inherited from TemplateNodeCreator< TemplateNodeBlock >
void mkpath (TemplateContextImpl *ci, const QCString &fileName)
 
- Protected Attributes inherited from TemplateNodeCreator< TemplateNodeBlock >
QCString m_templateName
 
int m_line
 

Detailed Description

Class representing a 'block' tag in a template.

Definition at line 3381 of file template.cpp.

Constructor & Destructor Documentation

TemplateNodeBlock::TemplateNodeBlock ( TemplateParser parser,
TemplateNode parent,
int  line,
const QCString &  data 
)
inline

Definition at line 3384 of file template.cpp.

References m_blockName, m_nodes, TemplateParser::parse(), TemplateParser::removeNextToken(), TemplateParser::templateName(), TRACE, and TemplateParser::warn().

{
TRACE(("{TemplateNodeBlock(%s)\n",data.data()));
m_blockName = data;
if (m_blockName.isEmpty())
{
parser->warn(parser->templateName(),line,"block tag without name");
}
QStrList stopAt;
stopAt.append("endblock");
parser->parse(this,line,stopAt,m_nodes);
parser->removeNextToken(); // skip over endblock
TRACE(("}TemplateNodeBlock(%s)\n",data.data()));
}

Member Function Documentation

QCString TemplateNodeBlock::name ( ) const
inline

Definition at line 3446 of file template.cpp.

References m_blockName.

Referenced by TemplateBlockContext::add(), and TemplateBlockContext::push().

{
return m_blockName;
}
void TemplateNodeBlock::render ( FTextStream ts,
TemplateContext c 
)
inlinevirtual

Implements TemplateNode.

Definition at line 3400 of file template.cpp.

References TemplateStruct::alloc(), TemplateContextImpl::blockContext(), TemplateImpl::engine(), TemplateEngine::enterBlock(), TemplateAutoRef< T >::get(), TemplateBlockContext::get(), TemplateNodeCreator< TemplateNodeBlock >::getTemplate(), TemplateEngine::leaveBlock(), m_blockName, TemplateNodeCreator< T >::m_line, TemplateNodeCreator< TemplateNodeBlock >::m_line, m_nodes, TemplateNodeCreator< T >::m_templateName, TemplateNodeCreator< TemplateNodeBlock >::m_templateName, TemplateBlockContext::pop(), TemplateContextImpl::pop(), TemplateBlockContext::push(), TemplateContextImpl::push(), TemplateNodeList::render(), render(), TemplateStruct::set(), TemplateContextImpl::set(), and TemplateContextImpl::setLocation().

Referenced by render().

{
TemplateContextImpl *ci = dynamic_cast<TemplateContextImpl*>(c);
if (ci==0) return; // should not happen
if (t)
{
// remove block from the context, so block.super can work
if (nb) // block is overruled
{
ci->push();
QGString super;
FTextStream ss(&super);
// get super block of block nb
if (sb && sb!=nb && sb!=this) // nb and sb both overrule this block
{
sb->render(ss,c); // render parent of nb to string
}
else if (nb!=this) // only nb overrules this block
{
m_nodes.render(ss,c); // render parent of nb to string
}
// add 'block.super' variable to allow access to parent block content
superBlock->set("super",TemplateVariant(super.data(),TRUE));
ci->set("block",superBlock.get());
// render the overruled block contents
nb->m_nodes.render(ts,c);
t->engine()->leaveBlock();
ci->pop();
// re-add block to the context
ci->blockContext()->push(nb);
}
else // block has no overrule
{
m_nodes.render(ts,c);
t->engine()->leaveBlock();
}
}
}

Member Data Documentation

QCString TemplateNodeBlock::m_blockName
private

Definition at line 3452 of file template.cpp.

Referenced by name(), render(), and TemplateNodeBlock().

TemplateNodeList TemplateNodeBlock::m_nodes
private

Definition at line 3453 of file template.cpp.

Referenced by render(), and TemplateNodeBlock().


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