Minnal C++ Servlet Container  1.7.0
Developed by Sans Pareil Technologies, Inc. (SPT)
 All Classes Namespaces Files Functions Variables Typedefs Macros Pages
spt::servlet::templating::TemplateManager Class Reference

A manager class used to abstract interactions with the templating engine. More...

#include <TemplateManager.h>

Public Member Functions

void init (spt::servlet::model::ServerConfigurationPtr configuration)
 Initialise the template engine with configuration from the server configuration file (minnal.xml). More...
 
void setInterval (long interval)
 
void addDirectory (const std::string &path)
 Add the specified directory to the template engine search path. More...
 
std::string expand (const std::string &templateName, ctemplate::TemplateDictionary *data)
 Convenience method used to return the expanded representation of the specified template using the specified data dictionary. More...
 
void reload (Poco::Timer &timer)
 Callback method invoked by the timer after the timer interval has expired. More...
 
std::string getFilePath (const std::string &templateName)
 Return the filesytem path for the template by searching within the template directory search path(s). More...
 

Static Public Member Functions

static TemplateManagergetTemplateManager ()
 

Protected Member Functions

ctemplate::TemplateCache * getCache ()
 

Detailed Description

A manager class used to abstract interactions with the templating engine.

Minnal uses Google ctemplate as the templating engine. This class exists primarily to run a timer that signlas the template engine to reload any templates modified on disk.

Date
Created 2014/09/29 21:50:41
Author
Rakesh
Version
Id
TemplateManager.h 5632 2014-10-06 22:04:21Z rakesh
Since
1.6.3

Member Function Documentation

void spt::servlet::templating::TemplateManager::addDirectory ( const std::string &  path)

Add the specified directory to the template engine search path.

The first time this method is invoked, sets the specified directory as the template engine root directory. Additional invocations will add the specified directory as alternate root directories in which templates are stored.

Parameters
pathThe path from which templates are to be loaded.
std::string spt::servlet::templating::TemplateManager::expand ( const std::string &  templateName,
ctemplate::TemplateDictionary *  data 
)

Convenience method used to return the expanded representation of the specified template using the specified data dictionary.

Parameters
templateNameThe name of the template that is to be loaded and expanded by the template engine.
dataThe data dictionary to use to expand the template.
Returns
The string that represents the expanded template.
ctemplate::TemplateCache* spt::servlet::templating::TemplateManager::getCache ( )
protected
std::string spt::servlet::templating::TemplateManager::getFilePath ( const std::string &  templateName)

Return the filesytem path for the template by searching within the template directory search path(s).

Parameters
templateNameThe name of the template as specified to the template engine.
Returns
The path to the location of the template
static TemplateManager& spt::servlet::templating::TemplateManager::getTemplateManager ( )
static
Returns
Returns the singleton instance of the template manager.
void spt::servlet::templating::TemplateManager::init ( spt::servlet::model::ServerConfigurationPtr  configuration)

Initialise the template engine with configuration from the server configuration file (minnal.xml).

Parameters
configurationThe server configuration information.
void spt::servlet::templating::TemplateManager::reload ( Poco::Timer &  timer)

Callback method invoked by the timer after the timer interval has expired.

Parameters
timerThe timer instance that invoked the callback
void spt::servlet::templating::TemplateManager::setInterval ( long  interval)
inline
Parameters
intervalThe periodic interval at which the timer is to fire

The documentation for this class was generated from the following file: