Qore WebUtil Module Reference 1.6.2
|
this class manages templates based on files More...
#include <WebUtil.qm.dox.h>
Public Member Methods | |
constructor (int parse_opts=StaticTextTemplateBase::DefaultProgramOptions, *code pgm_setup) | |
creates the object with optional Program options More... | |
purge (string tname) | |
this method can be called when a resource is requested that no longer exists in case a template is stored for a file that was deleted | |
hash< HttpResponseInfo > | render (string tname, string path, date mtime, hash< auto > ctx, int code=200, *hash< auto > hdr) |
explicitly renders the given template with the given path and context argument More... | |
Private Member Methods | |
RWLock | rwl () |
read-write lock for managing template access | |
this class manages templates based on files
Appropriate locking is used so that requests to existing templates based on files that have been updated on the filesystem are recompiled on demand and any requests that come in contemporaneously will block until the template is recompiled from the updated source on the filesystem
WebUtil::TemplateFileManager::constructor | ( | int | parse_opts = StaticTextTemplateBase::DefaultProgramOptions , |
*code | pgm_setup | ||
) |
creates the object with optional Program options
parse_opts | the Program parse options for the template file programs |
pgm_setup | an optional closure or call reference taking a single Program argument to be called when initializing template programs to set up a custom template API, etc |
hash< HttpResponseInfo > WebUtil::TemplateFileManager::render | ( | string | tname, |
string | path, | ||
date | mtime, | ||
hash< auto > | ctx, | ||
int | code = 200 , |
||
*hash< auto > | hdr | ||
) |
explicitly renders the given template with the given path and context argument
tname | the template name, normally a relative path for a template file, however this could also be the absolute path |
path | the path to the template file |
mtime | the last modified date/time for the file, if this date is after any stored last modified date/time for the template, then the template is recompiled from source |
ctx | the context argument for the template |
code | the HTTP response code for the response, if not present then 200 "OK" is assumed |
hdr | any optional headers for the response (the "Content-Type" header is set from the templates "Content-Type" value automatically) |
code:
the HTTP response code corresponding to the code argumentbody:
the rendered templatehdr:
a hash of headers corresponding to the hdr argument plus the "Content-Type"
key set from the template's "Content-Type" value)