Renders a page by combining a theme's chrome with a single template body, using the TextTemplater to process the Velocity template and then running the dynamic component service over the result. Used for the simpler, non-themed page rendering path, for example the blank template used to render PDFs, as opposed to the full VelocityHtmlTemplater used for themed website and admin pages.
Implements: HtmlTemplater
Properties
| Property | Returns | Description |
|---|---|---|
| cssSources | Map<String,List<String>> | The CSS resources pushed onto the current request so far, keyed by media type. |
| jsSources | Map<String,List<String>> | The JS resources pushed onto the current request so far, keyed by group, with each group's sources in the order they were pushed. |
| lessSources | Map<String,List<String>> | The LESS resources pushed onto the current request so far, keyed by media type. Populated by pushLess. |
| webRoot | String | The configured web root path used when resolving template paths. |
Methods
writePage(String templatePath, Resource aThis, Map<String,String> params, OutputStream out) · writePage(String theme, String templatePath, Resource aThis, Map<String,String> params, OutputStream out) · getCssPaths(FileResource page) · getWebRoot() · getLessSources() · getCombinedPath(List paths) · pushJs(String source) · pushJs(String source, String group) · pushJs(String source, String group, Integer position) · getJsSources() · getJsSources(String group) · getCombinedJsPath(List<String> paths) · getCombinedJsPath(String group) · pushCss(String source, String media) · getCssSources() · getCombinedJsPaths(String group) · getCombinedCssPath(List<String> paths) · getClassName(Object resource) · pushCss(String source) · pushLess(String source, String media, Integer pos) · pushLess(String source, String media)
writePage(String templatePath, Resource aThis, Map<String,String> params, OutputStream out)
Returns: void
Renders the given resource, resolving the theme to use from the resource itself, for example checking whether it implements CommonResource and finding an appropriate theme from its root folder.
| Parameter | Description |
|---|---|
templatePath | the template path to render |
aThis | the resource being rendered, used to resolve which theme applies |
params | request parameters made available to the template |
out | the stream the rendered page is written to |
writePage(String theme, String templatePath, Resource aThis, Map<String,String> params, OutputStream out)
Returns: void
Generates a templated page with the given theme and template. The theme controls the chrome, ie the menu, header and footer, while the template controls the layout of this specific page, such as a contacts list or a calendar. The rendered body is then passed through the dynamic component service before being written out.
| Parameter | Description |
|---|---|
theme | the theme to render the page's chrome with |
templatePath | the template path to render as the page body |
aThis | the resource being rendered |
params | request parameters made available to the template |
out | the stream the rendered page is written to |
getCssPaths(FileResource page)
Returns: List<String>
The CSS resource paths required to render the given page. Not implemented for this templater, always returns an empty list.
| Parameter | Description |
|---|---|
page | the page to resolve CSS paths for |
getWebRoot()
Returns: String
The configured web root path used when resolving template paths.
getLessSources()
Returns: Map<String,List<String>>
The LESS resources pushed onto the current request so far, keyed by media type. Populated by pushLess.
getCombinedPath(List paths)
Returns: String
Munges the given LESS or CSS resource paths into a single combined path that the LESS compilation endpoint can expand back out, with a cache-busting version hash appended.
| Parameter | Description |
|---|---|
paths | the resource paths to combine, either plain strings or ComponentHtmlTemplater.SourceAndPosition instances |
pushJs(String source)
Returns: String
Registers a JS resource to be included on the current page, for the default group.
| Parameter | Description |
|---|---|
source | the path of the JS resource to include |
pushJs(String source, String group)
Returns: String
Registers a JS resource to be included on the current page, for the given group, with no explicit position.
| Parameter | Description |
|---|---|
source | the path of the JS resource to include |
group | the group the resource is added to, groups are typically rendered together |
pushJs(String source, String group, Integer position)
Returns: String
Registers a JS resource to be included on the current page, for the given group and position. Duplicate sources within the same group are not added twice.
| Parameter | Description |
|---|---|
source | the path of the JS resource to include |
group | the group the resource is added to, groups are typically rendered together |
position | the position within the group to insert the resource at, may be null to append |
getJsSources()
Returns: Map<String,List<String>>
The JS resources pushed onto the current request so far, keyed by group, with each group's sources in the order they were pushed.
getJsSources(String group)
Returns: List<String>
The JS resource paths pushed onto the current request so far for the given group, in the order they were pushed.
| Parameter | Description |
|---|---|
group | the group to look up pushed JS resources for |
getCombinedJsPath(List<String> paths)
Returns: String
Munges the given JS resource paths into a single combined path that the JS combine endpoint can expand back out, with a cache-busting version hash appended.
| Parameter | Description |
|---|---|
paths | the JS resource paths to combine |
getCombinedJsPath(String group)
Returns: String
Munges the JS resources pushed for the given group into a single combined path, with a cache-busting version hash appended.
| Parameter | Description |
|---|---|
group | the group whose pushed JS resources are combined |
pushCss(String source, String media)
Returns: String
Registers a CSS resource to be included on the current page, for the given media type.
| Parameter | Description |
|---|---|
source | the path of the CSS resource to include |
media | the CSS media attribute to render the resource under, defaults to an empty string if null |
getCssSources()
Returns: Map<String,List<String>>
The CSS resources pushed onto the current request so far, keyed by media type.
getCombinedJsPaths(String group)
Returns: List<String>
Munges the JS resources pushed for the given group into one or more combined paths, splitting into multiple combined paths if the munged path would exceed the maximum length.
| Parameter | Description |
|---|---|
group | the group whose pushed JS resources are combined |
getCombinedCssPath(List<String> paths)
Returns: String
Munges the given CSS resource paths into a single combined path that the CSS combine endpoint can expand back out, with a cache-busting version hash appended.
| Parameter | Description |
|---|---|
paths | the CSS resource paths to combine |
getClassName(Object resource)
Returns: String
The simple, unqualified class name of the given object, used by templates for example to derive a CSS class from the type of page being rendered.
| Parameter | Description |
|---|---|
resource | the object to get the simple class name of |
pushCss(String source)
Returns: String
Registers a CSS resource to be included on the current page, with no specific media type.
| Parameter | Description |
|---|---|
source | the path of the CSS resource to include |
pushLess(String source, String media, Integer pos)
Returns: String
Registers a LESS resource to be included on the current page, for the given media type and position.
| Parameter | Description |
|---|---|
source | the path of the LESS resource to include |
media | the CSS media attribute to render the compiled resource under |
pos | the position within the media group to insert the resource at, may be null to append |
pushLess(String source, String media)
Returns: String
Registers a LESS resource to be included on the current page, for the given media type, with no explicit position.
| Parameter | Description |
|---|---|
source | the path of the LESS resource to include |
media | the CSS media attribute to render the compiled resource under |