22 #include "template_p.h"
26 #include "exception.h"
29 #include "rendercontext.h"
31 #include <QtCore/QLoggingCategory>
33 Q_LOGGING_CATEGORY(CUTELEE_TEMPLATE,
"cutelee.template")
41 Parser p(l.tokenize(m_smartTrim ? Lexer::SmartTrim : Lexer::NoSmartTrim), q);
46 TemplateImpl::TemplateImpl(
Engine const *engine, QObject *parent)
47 : QObject(parent), d_ptr(new TemplatePrivate(engine, false, this))
51 TemplateImpl::TemplateImpl(
Engine const *engine,
bool smartTrim,
53 : QObject(parent), d_ptr(new TemplatePrivate(engine, smartTrim, this))
57 TemplateImpl::~TemplateImpl() {
delete d_ptr; }
59 void TemplateImpl::setContent(
const QString &templateString)
62 if (templateString.isEmpty())
66 d->m_nodeList = d->compileString(templateString);
67 d->setError(NoError,
QString());
69 qCWarning(CUTELEE_TEMPLATE) << e.what();
70 d->setError(e.errorCode(), e.what());
77 QTextStream textStream(&output);
79 render(&outputStream, c);
87 c->clearExternalMedia();
92 d->m_nodeList.render(stream, c);
93 d->setError(NoError,
QString());
95 qCWarning(CUTELEE_TEMPLATE) << e.what();
96 d->setError(e.errorCode(), e.what());
104 NodeList TemplateImpl::nodeList()
const
107 return d->m_nodeList;
110 void TemplateImpl::setNodeList(
const NodeList &list)
113 d->m_nodeList = list;
116 void TemplatePrivate::setError(
Error type,
const QString &message)
const
119 m_errorString = message;
131 return d->m_errorString;
134 Engine const *TemplateImpl::engine()
const
137 return d->m_engine.data();
The Context class holds the context to render a Template with.
RenderContext * renderContext() const
Cutelee::Engine is the main entry point for creating Cutelee Templates.
An exception for use when implementing template tags.
A list of Nodes with some convenience API for rendering them.
The OutputStream class is used to render templates to a QTextStream.
The Parser class processes a string template into a tree of nodes.
The Template class is a tree of nodes which may be rendered.
The Cutelee namespace holds all public Cutelee API.