KTextTemplate::InMemoryTemplateLoader Class
class KTextTemplate::InMemoryTemplateLoaderThe InMemoryTemplateLoader loads Templates set dynamically in memory. More...
Header: | #include <KTextTemplate/TemplateLoader> |
CMake: | find_package(KF6 REQUIRED COMPONENTS TextTemplate) target_link_libraries(mytarget PRIVATE KF6::TextTemplate) |
Inherits: | KTextTemplate::AbstractTemplateLoader |
Public Functions
InMemoryTemplateLoader() | |
void | setTemplate(const QString &name, const QString &content) |
Detailed Description
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.
Member Function Documentation
InMemoryTemplateLoader::InMemoryTemplateLoader()
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.