|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjuzu.template.Template
public abstract class Template
A template as seen by an application. A template is identified by its
path and can used to produce markup.
Templates perform rendering using a parameter map and a locale as inputs and produces a markup response.
Templates can be used to produce a controller response using the API like
public Response.Content index() {
return template.ok();
}
The template API offers also methods for returning other response status:
template.notFound()template.status(code)Template rendering can also be parameterized with a parameter map:
public Response.Content index() {
return template.with(parameters).ok();
}
Template can be parameterized using a fluent API with the Template.Builder object provided by the with()
method:
return template.with().set("date", new java.util.Date()).ok()
The template compiler produces also a subclass of the template that can be used instead of this base template class.
This sub class overrides the with() method to return a builder that provides typed methods when the
template declares parameters:
return template.with().date(new java.util.Date()).ok()
| Nested Class Summary | |
|---|---|
class |
Template.Builder
A builder providing a fluent syntax for rendering a template. |
| Constructor Summary | |
|---|---|
Template(juzu.impl.plugin.template.TemplatePlugin plugin,
juzu.impl.common.Path path)
|
|
Template(juzu.impl.plugin.template.TemplatePlugin plugin,
String path)
|
|
| Method Summary | ||
|---|---|---|
juzu.impl.common.Path |
getPath()
Returns the template path. |
|
Response.Content |
notFound()
Renders the template. |
|
Response.Content |
notFound(Locale locale)
Renders the template. |
|
Response.Content |
notFound(Map<String,?> parameters)
Renders the template. |
|
Response.Content |
notFound(Map<String,?> parameters,
Locale locale)
Renders the template. |
|
Response.Content |
ok()
Renders the template. |
|
Response.Content |
ok(Locale locale)
Renders the template. |
|
Response.Content |
ok(Map<String,?> parameters)
Renders the template and set the response on the current RequestContext. |
|
Response.Content |
ok(Map<String,?> parameters,
Locale locale)
Renders the template. |
|
|
renderTo(A appendable)
Renders the template to the specified appendable. |
|
|
renderTo(A appendable,
Locale locale)
Renders the template to the specified appendable. |
|
|
renderTo(A appendable,
Map<String,?> parameters)
Renders the template to the specified appendable. |
|
void |
renderTo(Stream printer)
Renders the template to the specified printer. |
|
void |
renderTo(Stream printer,
Locale locale)
Renders the template to the specified printer. |
|
void |
renderTo(Stream printer,
Map<String,?> parameters)
Renders the template to the specified printer. |
|
String |
toString()
|
|
Template.Builder |
with()
Returns a builder to further customize the template rendering. |
|
Template.Builder |
with(Locale locale)
Returns a builder to further customize the template rendering. |
|
Template.Builder |
with(Map<String,?> parameters)
Returns a builder to further customize the template rendering. |
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Template(juzu.impl.plugin.template.TemplatePlugin plugin,
String path)
public Template(juzu.impl.plugin.template.TemplatePlugin plugin,
juzu.impl.common.Path path)
| Method Detail |
|---|
public final juzu.impl.common.Path getPath()
public final String toString()
toString in class Objectpublic final Response.Content ok()
public final Response.Content ok(Locale locale)
locale - the locale
public final Response.Content ok(Map<String,?> parameters)
RequestContext.
parameters - the parameters
public final Response.Content ok(Map<String,?> parameters,
Locale locale)
parameters - the parameterslocale - the locale
public final Response.Content notFound()
public final Response.Content notFound(Locale locale)
locale - the locale
public final Response.Content notFound(Map<String,?> parameters)
parameters - the parameters
public final Response.Content notFound(Map<String,?> parameters,
Locale locale)
parameters - the parameterslocale - the locale
public <A extends Appendable> A renderTo(A appendable)
throws TemplateExecutionException,
UndeclaredIOException
appendable - the appendable
TemplateExecutionException - any execution exception
UndeclaredIOException - any io exception
public <A extends Appendable> A renderTo(A appendable,
Locale locale)
throws TemplateExecutionException,
UndeclaredIOException
appendable - the appendablelocale - the locale
TemplateExecutionException - any execution exception
UndeclaredIOException - any io exception
public <A extends Appendable> A renderTo(A appendable,
Map<String,?> parameters)
throws TemplateExecutionException,
UndeclaredIOException
appendable - the appendableparameters - the attributes
TemplateExecutionException - any execution exception
UndeclaredIOException - any io exception
public void renderTo(Stream printer)
throws TemplateExecutionException,
UndeclaredIOException
printer - the printer
TemplateExecutionException - any execution exception
UndeclaredIOException - any io exception
public void renderTo(Stream printer,
Locale locale)
throws TemplateExecutionException,
UndeclaredIOException
printer - the printerlocale - the locale
TemplateExecutionException - any execution exception
UndeclaredIOException - any io exception
public void renderTo(Stream printer,
Map<String,?> parameters)
throws TemplateExecutionException,
UndeclaredIOException
printer - the printerparameters - the attributes
TemplateExecutionException - any execution exception
UndeclaredIOException - any io exceptionpublic Template.Builder with()
public Template.Builder with(Map<String,?> parameters)
public Template.Builder with(Locale locale)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||