2
This file is part of the Grantlee template system.
4
Copyright (c) 2010 Stephen Kelly <steveire@gmail.com>
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either version
9
2.1 of the Licence, or (at your option) any later version.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Lesser General Public License for more details.
16
You should have received a copy of the GNU Lesser General Public
17
License along with this library. If not, see <http://www.gnu.org/licenses/>.
21
2
#include <QCoreApplication>
26
7
#include "grantlee_paths.h"
28
static void renderTemplate( Grantlee::Engine *engine, const QString &templateName )
9
static void renderTemplate( Grantlee::Engine *engine, const QString &templateName ) {
31
11
Grantlee::Template t = engine->loadByName( templateName );
34
15
qDebug() << t->errorString();
35
Q_ASSERT( !"Failed to get template" );
16
Q_ASSERT(!"Failed to get template");
38
19
Grantlee::Context c;
40
QString result = t->render( &c );
21
QString result = t->render(&c);
43
25
qDebug() << t->errorString();
44
Q_ASSERT( !"Failed to render template" );
26
Q_ASSERT(!"Failed to render template");
47
29
qDebug() << result;
50
int main( int argc, char **argv )
32
int main(int argc, char **argv)
52
QCoreApplication app( argc, argv );
34
QCoreApplication app(argc, argv);
54
36
Grantlee::Engine *engine = new Grantlee::Engine();
56
38
Grantlee::FileSystemTemplateLoader::Ptr loader = Grantlee::FileSystemTemplateLoader::Ptr( new Grantlee::FileSystemTemplateLoader() );
57
39
loader->setTemplateDirs( QStringList()
58
<< ( QCoreApplication::applicationDirPath() + "/template_dir_1" )
59
<< ( QCoreApplication::applicationDirPath() + "/template_dir_2" )
40
<< ( QCoreApplication::applicationDirPath() + "/template_dir_1" )
41
<< ( QCoreApplication::applicationDirPath() + "/template_dir_2" )
62
44
engine->addTemplateLoader( loader );