this is the static base class for all template Program container classes
More...
#include <WebUtil.qm.dox.h>
|
static string | add (Qore::Program p, string fn, string name, string src) |
| adds a template function to a template Program object More...
|
|
static string | getContentType (string name) |
| returns the content type from the file name, ignores any leading "q" in the extensions, assuming a template
|
|
|
const | DefaultProgramOptions = PO_REQUIRE_OUR|PO_NO_TOP_LEVEL_STATEMENTS|PO_NO_INHERIT_USER_FUNC_VARIANTS|PO_NO_INHERIT_GLOBAL_VARS|PO_NO_USER_CLASSES|PO_NO_TERMINAL_IO |
| default parse options for template Programs
|
|
|
static bool | doBlock (string end, reference< string > src, string type, reference< int > i, reference< list< hash > > l) |
| a helper method used in parsing
|
|
static string | getCode (bool bare_refs, string fmt) |
| a helper method that strips dollar signs from code when PO_ALLOW_BARE_REFS is set in the template program
|
|
this is the static base class for all template Program container classes
◆ add()
static string WebUtil::StaticTextTemplateBase::add |
( |
Qore::Program |
p, |
|
|
string |
fn, |
|
|
string |
name, |
|
|
string |
src |
|
) |
| |
|
static |
adds a template function to a template Program object
- Example:
string qhtml = "<form id=\"upload_form\" enctype=\"multipart/form-data\" method=\"post\" action=\"{{ $URL_PREFIX }}upload-file">
<fieldset class=\"workflow_list\">
<legend>Step 1: Select Workflow</legend>
<select class=\"worfklows\" name=\"workflow\" id=\"workflow\">
{% foreach my hash<auto> $h ($ctx.workflows.pairIterator()) { %}
<option value="{{ $h.key }}">{{ $h.value.label }}</option>
{% } %}
</select>
</fieldset>
</form>";
StaticTextTemplateBase::add(p, "/html/index.qhtml", qhtml, "t0");
- Parameters
-
p | the Program object to add the template function to |
fn | the name of the template function |
name | the name of the template |
src | the source of the template; Qore source code is delimited as follows:
- expressions: Qore expressions are delimited by double curly brackets:
{{ }} ; such expressions are expected to return a string value that will be inserted directly into the text generated by the template
- statements: Qore statements are delimited by a curly bracket and percent sign:
{% %} ; these statements can be any Qore code legal for the template Program object; for example loop constructs are often used (see the example above)
|
The ctx hash variable is always present in the template code; this is the call context variable, and is set to the same value as the cx argument in HttpServer::AbstractHttpRequestHandler::handleRequest() plus any context added by the actual handler handing the request. In the example above, a "workflows"
key assigned to a hash has been added to the call context variable.
- Returns
- the source code of the generated template (without Program overhead)