Exchange interface
A JavaScript object implementing the Exchange
interface represents an HTTP request / response exchange.
Construction
Constructed by the Platform when a plugin handles a request, and is passed in as the first argument to the handler function.
Interface
property request
The Request
object for this HTTP exchange.
property response
The Response
object for this HTTP exchange.
function render(view, templateName)
This function generates an HTTP response body by rendering a Template
. The MIME type is set automatically from the kind
property of the template.
If the template is HTML, the response will include the standard ‘chrome’ (header, footer, menus, navigation, etc) with the rendered template as the content of the page.
The templateName
argument is optional. If it’s not specified or is null
, then an implied name will be used. This is the last path element in the path passed to the Plugin
’s respond()
function.
Note you can use a standard template as well as your plugin’s templates. This is often useful when doing common actions, for example, presenting a template object for the user to fill in and save with the std:new_object_editor
template.
As well as the values required by the template, the view
may also contain the following keys:
key pageTitle
Avoid the use of this property, use the pageTitle() template function instead.
The title for the page. This is included in the page’s <title>
tag, and in the heading bar just above the main content of the page.
The value is HTML escaped for safety.
key layout
Avoid the use of this property, use the layout template functions instead.
Optional. Possible values are:
false |
No layout. Use for AJAX responses. |
"std:standard" |
The standard layout, including all the normal Haplo navigation. |
null , undefined |
Use the std:standard layout. |
"std:wide" |
A version of the standard layout, including all the normal Haplo navigation, with a wider content area. |
"std:minimal" |
Minimal layout, using the Haplo styles and client side resource handling, but without the main navigation. |
"std:empty" |
Empty layout, using the Haplo styles and client side resource handling, within the standard width, but without any chrome. |
"std:clear" |
Clear layout, using the Haplo styles and client side resource handling, but with nothing except the rendered HTML in the body tag. |
If the template is not HTML, this property is ignored.
If no layout is specified in the view, the "std:standard"
layout is used.
See Layouts for more information.
key backLink
Avoid the use of this property, use the backLink() template function instead.
Optional. The URL for the optional back link in the top left of the page.
key backLinkText
Avoid the use of this property, use the backLink() template function instead.
Optional. The label for the back link. If backLink
if specified and backLinkText
is not, then the default text of “Back” is used.
function renderIntoSidebar(view, templateName)
Render a template, and append the result to the content displayed in the Sidebar.
Similar to render()
in usage, but the templateName
argument must be provided.
function appendSidebarHTML(html)
Append the given html
to the content displayed in the Sidebar.