NuriaProject Framework
0.1
The NuriaProject Framework
|
A template loader which loads templates from files. More...
#include <filetemplateloader.hpp>
Public Member Functions | |
FileTemplateLoader (QObject *parent=0) | |
FileTemplateLoader (const QDir &path, QObject *parent=0) | |
FileTemplateLoader (const QVector< QDir > &paths, QObject *parent=0) | |
~FileTemplateLoader () override | |
void | addSearchPath (const QDir &path) |
bool | hasTemplate (const QString &name) override |
bool | hasTemplateChanged (const QString &name, const QDateTime &since) override |
QByteArray | load (const QString &name) override |
QVector< QDir > | searchPaths () const |
void | setSearchPaths (const QVector< QDir > &paths) const |
void | setSuffix (const QString &suffix) |
QString | suffix () const |
![]() | |
TemplateLoader (QObject *parent=0) | |
~TemplateLoader () override | |
Additional Inherited Members | |
![]() | |
void | allTemplatesChanged () |
void | templateChanged (const QString &name) |
A template loader which loads templates from files.
This template loader tries to load files from one or more paths in the file-system. This includes paths in Qt resources.
Search paths are tried from the one added first to the one added last. You can also define a common file suffix, which is appended to every template name internally. Use this if all your templates have a common suffix, like ".twig", and don't want to write it in the Twig code.
Directory traversal attacks, meaning traversing outside of the given search paths, are not possible.
|
explicit |
Default constructor.
|
explicit |
Constructor which uses path as search path.
|
explicit |
Contstructor which uses paths as search paths.
|
override |
Destructor.
void Nuria::FileTemplateLoader::addSearchPath | ( | const QDir & | path | ) |
Adds path to the list of search paths.
|
overridevirtual |
Returns true
if a template name is known to the template loader. The default implementation returns true
if name is not empty.
Reimplemented from Nuria::TemplateLoader.
|
overridevirtual |
Returns true
if name has been changed since. The default implementation always returns false
, which is fine for template loaders making use of the changed signals in this class.
Reimplemented from Nuria::TemplateLoader.
|
overridevirtual |
Returns the template data of the template called name. The default implementation returns name.
A empty result is treated as failure.
Reimplemented from Nuria::TemplateLoader.
QVector< QDir > Nuria::FileTemplateLoader::searchPaths | ( | ) | const |
Returns the current search paths.
void Nuria::FileTemplateLoader::setSearchPaths | ( | const QVector< QDir > & | paths | ) | const |
Replaces the current search path list with paths.
void Nuria::FileTemplateLoader::setSuffix | ( | const QString & | suffix | ) |
Sets the file suffix, which is appended internally to every template name.
QString Nuria::FileTemplateLoader::suffix | ( | ) | const |
Returns the file suffix.