Plugin response generation
The Platform provides many features to help you generate the response HTML for your request handler. Note that the use of templates is built into the Exchange
object passed into your request handler, and you only need to use the template()
function if you’re doing something special.
Interface
function template(templateName)
Retrieve one of the plugin’s template objects.
For request handling, it’s often not necessary to use this directly, but it’s useful for rendering things as HTML in other parts of the plugin.
It can also be used to retrieve a standard template, the names of which all begin std:
.
function globalTemplateFunction(name, templateFunction)
Define a plugin defined template function for use in this and all other plugins.
As the function is available to all plugins, the name must contain an :
character, and should be in an appropriate namespace.
The templateFunction
is called for each occurrence of the template function when a template is rendered, with the arguments from the template and this
set to a TemplateFunctionThis
object.
property staticDirectoryUrl
The public facing path to the static
directory, used for referring to the static resources.
The path returned does not contain a trailing /
.
function rewriteCSS(css)
Given a string containing some CSS, rewrite it to reflect the current application.
The replacements are the same as the CSS rewriting for static files.