KTextTemplate::InMemoryTemplateLoader

Search for usage in LXR

KTextTemplate::InMemoryTemplateLoader Class Reference

#include <KTextTemplate/templateloader.h>

Inheritance diagram for KTextTemplate::InMemoryTemplateLoader:

Public Member Functions

bool canLoadTemplate (const QString &name) const override
 
std::pair< QString, QStringgetMediaUri (const QString &fileName) const override
 
Template loadByName (const QString &name, Engine const *engine) const override
 
void setTemplate (const QString &name, const QString &content)
 
- Public Member Functions inherited from KTextTemplate::AbstractTemplateLoader
virtual ~AbstractTemplateLoader ()
 

Detailed Description

The InMemoryTemplateLoader loads Templates set dynamically in memory.

This class is mostly used for testing purposes, but can also be used for simple uses of KTextTemplate.

Templates can be made available using the setTemplate method, and will then be retrieved by the KTextTemplate::Engine as appropriate.

Definition at line 180 of file templateloader.h.

Constructor & Destructor Documentation

◆ InMemoryTemplateLoader()

InMemoryTemplateLoader::InMemoryTemplateLoader ( )

Definition at line 55 of file templateloader.cpp.

Member Function Documentation

◆ canLoadTemplate()

bool InMemoryTemplateLoader::canLoadTemplate ( const QString & name) const
overridevirtual

Return true if a Template identified by name exists and can be loaded.

Implements KTextTemplate::AbstractTemplateLoader.

Definition at line 177 of file templateloader.cpp.

◆ getMediaUri()

std::pair< QString, QString > InMemoryTemplateLoader::getMediaUri ( const QString & fileName) const
overridevirtual

Return a complete URI for media identified by fileName.

Implements KTextTemplate::AbstractTemplateLoader.

Definition at line 191 of file templateloader.cpp.

◆ loadByName()

Template InMemoryTemplateLoader::loadByName ( const QString & name,
Engine const * engine ) const
overridevirtual

Load a Template called name.

Return an invalid Template if no content by that name exists.

Implements KTextTemplate::AbstractTemplateLoader.

Definition at line 182 of file templateloader.cpp.

◆ setTemplate()

void InMemoryTemplateLoader::setTemplate ( const QString & name,
const QString & content )

Add a template content to this Loader.

Example:

auto loader = QSharedPointer<InMemoryTemplateLoader::create();
loader->setTemplate( "name_template", "My name is {{ name }}" );
loader->setTemplate( "age_template", "My age is {{ age }}" );
engine->addTemplateLoader( loader );
// Both templates may now be retrieved by calling Engine::loadByName.

Definition at line 172 of file templateloader.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:42 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.