|
||||||||||
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.
Template can be rendered with many methods that will affect the current execution. Those methods will implicitly set
the produced markup response on the MimeContext
using the MimeContext.setResponse(juzu.Response.Content)
method: render()
, render(java.util.Locale)
, render(java.util.Map)
, render(java.util.Map, java.util.Locale)
,
notFound()
, notFound(java.util.Locale)
, notFound(java.util.Map)
, notFound(java.util.Map, java.util.Locale)
,
ok()
, ok(java.util.Locale)
, ok(java.util.Map)
, ok(java.util.Map, java.util.Locale)
.
Template can be parameterized using a fluent API with the Template.Builder
object provided by the with()
method:
template.with().set("date", new java.util.Date()).render()
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:
template.with().date(new java.util.Date()).render()
Nested Class Summary | |
---|---|
class |
Template.Builder
A builder providing a fluent syntax for rendering a template. |
Constructor Summary | |
---|---|
Template(juzu.impl.plugin.template.TemplatePlugin applicationContext,
juzu.impl.common.Path path,
Class<? extends juzu.impl.template.spi.TemplateStub> stubType)
|
|
Template(juzu.impl.plugin.template.TemplatePlugin applicationContext,
String path,
Class<? extends juzu.impl.template.spi.TemplateStub> stubType)
|
Method Summary | ||
---|---|---|
juzu.impl.common.Path |
getPath()
Returns the template path. |
|
Response.Content |
notFound()
Renders the template and set a 404 response on the current MimeContext . |
|
Response.Content |
notFound(Locale locale)
Renders the template and set a 404 response on the current MimeContext . |
|
Response.Content |
notFound(Map<String,?> parameters)
Renders the template and set a 404 response on the current MimeContext . |
|
Response.Content<Stream.Char> |
notFound(Map<String,?> parameters,
Locale locale)
Renders the template and set a 404 response on the current MimeContext . |
|
Response.Content |
ok()
Renders the template and set the response on the current MimeContext . |
|
Response.Content |
ok(Locale locale)
Renders the template and set the response on the current MimeContext . |
|
Response.Content |
ok(Map<String,?> parameters)
Renders the template and set the response on the current MimeContext . |
|
Response.Content<Stream.Char> |
ok(Map<String,?> parameters,
Locale locale)
Renders the template and set the response on the current MimeContext . |
|
Response.Render |
render()
Renders the template and returns a render response. |
|
Response.Render |
render(Locale locale)
Renders the template and set a the response on the current MimeContext . |
|
Response.Render |
render(Map<String,?> parameters)
Renders the template and set a the response on the current MimeContext . |
|
Response.Render |
render(Map<String,?> parameters,
Locale locale)
Renders the template and set a the response on the current MimeContext . |
|
|
renderTo(A appendable)
Renders the template to the specified appendable, the current MimeContext will not be affected. |
|
|
renderTo(A appendable,
Locale locale)
Renders the template to the specified appendable, the current MimeContext will not be affected. |
|
|
renderTo(A appendable,
Map<String,?> parameters)
Renders the template to the specified appendable, the current MimeContext will not be affected. |
|
|
renderTo(A appendable,
Map<String,?> parameters,
Locale locale)
Renders the template to the specified appendable, the current MimeContext will not be affected. |
|
void |
renderTo(Stream.Char printer)
Renders the template to the specified printer, the current MimeContext will not be affected. |
|
void |
renderTo(Stream.Char printer,
Locale locale)
Renders the template to the specified printer, the current MimeContext will not be affected. |
|
void |
renderTo(Stream.Char printer,
Map<String,?> parameters)
Renders the template to the specified printer, the current MimeContext will not be affected. |
|
void |
renderTo(Stream.Char printer,
Map<String,?> parameters,
Locale locale)
Renders the template to the specified printer, the current MimeContext will not be affected. |
|
String |
toString()
|
|
abstract 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. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Template(juzu.impl.plugin.template.TemplatePlugin applicationContext, String path, Class<? extends juzu.impl.template.spi.TemplateStub> stubType)
public Template(juzu.impl.plugin.template.TemplatePlugin applicationContext, juzu.impl.common.Path path, Class<? extends juzu.impl.template.spi.TemplateStub> stubType)
Method Detail |
---|
public final juzu.impl.common.Path getPath()
public final String toString()
toString
in class Object
public Response.Render render() throws TemplateExecutionException, UndeclaredIOException
TemplateExecutionException
UndeclaredIOException
public Response.Render render(Locale locale) throws TemplateExecutionException, UndeclaredIOException
MimeContext
.
locale
- the locale
TemplateExecutionException
UndeclaredIOException
public Response.Render render(Map<String,?> parameters) throws TemplateExecutionException, UndeclaredIOException
MimeContext
.
parameters
- the parameters
TemplateExecutionException
UndeclaredIOException
public Response.Render render(Map<String,?> parameters, Locale locale) throws TemplateExecutionException, UndeclaredIOException
MimeContext
.
parameters
- the parameterslocale
- the locale
TemplateExecutionException
UndeclaredIOException
public final Response.Content ok()
MimeContext
.
public final Response.Content ok(Locale locale)
MimeContext
.
locale
- the locale
public final Response.Content ok(Map<String,?> parameters)
MimeContext
.
parameters
- the parameters
public final Response.Content<Stream.Char> ok(Map<String,?> parameters, Locale locale)
MimeContext
.
parameters
- the parameterslocale
- the locale
public final Response.Content notFound()
MimeContext
.
public final Response.Content notFound(Locale locale)
MimeContext
.
locale
- the locale
public final Response.Content notFound(Map<String,?> parameters)
MimeContext
.
parameters
- the parameters
public final Response.Content<Stream.Char> notFound(Map<String,?> parameters, Locale locale)
MimeContext
.
parameters
- the parameterslocale
- the locale
public <A extends Appendable> A renderTo(A appendable) throws TemplateExecutionException, UndeclaredIOException
MimeContext
will not be affected.
appendable
- the appendable
TemplateExecutionException
- any execution exception
UndeclaredIOException
- any io exceptionpublic <A extends Appendable> A renderTo(A appendable, Locale locale) throws TemplateExecutionException, UndeclaredIOException
MimeContext
will not be affected.
appendable
- the appendablelocale
- the locale
TemplateExecutionException
- any execution exception
UndeclaredIOException
- any io exceptionpublic <A extends Appendable> A renderTo(A appendable, Map<String,?> parameters) throws TemplateExecutionException, UndeclaredIOException
MimeContext
will not be affected.
appendable
- the appendableparameters
- the attributes
TemplateExecutionException
- any execution exception
UndeclaredIOException
- any io exceptionpublic <A extends Appendable> A renderTo(A appendable, Map<String,?> parameters, Locale locale) throws TemplateExecutionException, UndeclaredIOException
MimeContext
will not be affected.
appendable
- the appendableparameters
- the attributeslocale
- the locale
TemplateExecutionException
- any execution exception
UndeclaredIOException
- any io exceptionpublic void renderTo(Stream.Char printer) throws TemplateExecutionException, UndeclaredIOException
MimeContext
will not be affected.
printer
- the printer
TemplateExecutionException
- any execution exception
UndeclaredIOException
- any io exceptionpublic void renderTo(Stream.Char printer, Locale locale) throws TemplateExecutionException, UndeclaredIOException
MimeContext
will not be affected.
printer
- the printerlocale
- the locale
TemplateExecutionException
- any execution exception
UndeclaredIOException
- any io exceptionpublic void renderTo(Stream.Char printer, Map<String,?> parameters) throws TemplateExecutionException, UndeclaredIOException
MimeContext
will not be affected.
printer
- the printerparameters
- the attributes
TemplateExecutionException
- any execution exception
UndeclaredIOException
- any io exceptionpublic void renderTo(Stream.Char printer, Map<String,?> parameters, Locale locale) throws TemplateExecutionException, UndeclaredIOException
MimeContext
will not be affected.
printer
- the printerparameters
- the attributeslocale
- the locale
TemplateExecutionException
- any execution exception
UndeclaredIOException
- any io exceptionpublic abstract Template.Builder with()
public Template.Builder with(Locale locale)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |