Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## juzu.template
Class Template

    java.lang.Object
      juzu.template.Template

    public abstract class Template

extends Object

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()`

Author:
  Julien Viet

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, Class<? extends juzu.impl.template.spi.TemplateStub> stubType)`
`Template(juzu.impl.plugin.template.TemplatePlugin plugin, String path, Class<? extends juzu.impl.template.spi.TemplateStub> stubType)`

Method Summary
`juzu.impl.common.Path` | `getPath()` Returns the template path.
`Response.Render` | `notFound()` Renders the template.
`Response.Render` | `notFound(Locale locale)` Renders the template.
`Response.Render` | `notFound(Map<String,?> parameters)` Renders the template.
`Response.Render` | `notFound(Map<String,?> parameters, Locale locale)` Renders the template.
`Response.Render` | `ok()` Renders the template.
`Response.Render` | `ok(Locale locale)` Renders the template.
`Response.Render` | `ok(Map<String,?> parameters)` Renders the template and set the response on the current `MimeContext`.
`Response.Render` | `ok(Map<String,?> parameters, Locale locale)` Renders the template.
`void` | `render()` Renders the template and set the response on the current `MimeContext`
`void` | `render(Locale locale)` Renders the template and set a the response on the current `MimeContext`.
`void` | `render(Map<String,?> parameters)` Renders the template and set a the response on the current `MimeContext`.
`void` | `render(Map<String,?> parameters, Locale locale)` Renders the template and set a the response on the current `MimeContext`.
`
`<A extends Appendable> A`
` | `renderTo(A appendable)` Renders the template to the specified appendable.
`
`<A extends Appendable> A`
` | `renderTo(A appendable, Locale locale)` Renders the template to the specified appendable.
`
`<A extends Appendable> A`
` | `renderTo(A appendable, Map<String,?> parameters)` Renders the template to the specified appendable.
`void` | `renderTo(Stream.Char printer)` Renders the template to the specified printer.
`void` | `renderTo(Stream.Char printer, Locale locale)` Renders the template to the specified printer.
`void` | `renderTo(Stream.Char 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

### Template

    public Template(juzu.impl.plugin.template.TemplatePlugin plugin,
                    String path,
                    Class<? extends juzu.impl.template.spi.TemplateStub> stubType)

### Template

    public Template(juzu.impl.plugin.template.TemplatePlugin plugin,
                    juzu.impl.common.Path path,
                    Class<? extends juzu.impl.template.spi.TemplateStub> stubType)

Method Detail

### getPath

    public final juzu.impl.common.Path getPath()

  Returns the template path.

  Returns:
    the temlate path

### toString

    public final String toString()

  Overrides:
    `toString` in class `Object`

### render

    public void render()
                throws TemplateExecutionException,
                       UndeclaredIOException

  Renders the template and set the response on the current `MimeContext`

  Throws:
    `TemplateExecutionException`
    `UndeclaredIOException`

### render

    public void render(Locale locale)
                throws TemplateExecutionException,
                       UndeclaredIOException

  Renders the template and set a the response on the current `MimeContext`.

  Parameters:
    `locale` - the locale
  Throws:
    `TemplateExecutionException`
    `UndeclaredIOException`

### render

    public void render(Map<String,?> parameters)
                throws TemplateExecutionException,
                       UndeclaredIOException

  Renders the template and set a the response on the current `MimeContext`.

  Parameters:
    `parameters` - the parameters
  Throws:
    `TemplateExecutionException`
    `UndeclaredIOException`

### render

    public void render(Map<String,?> parameters,
                       Locale locale)
                throws TemplateExecutionException,
                       UndeclaredIOException

  Renders the template and set a the response on the current `MimeContext`.

  Parameters:
    `parameters` - the parameters
    `locale` - the locale
  Throws:
    `TemplateExecutionException`
    `UndeclaredIOException`

### ok

    public final Response.Render ok()

  Renders the template.

  Returns:
    the ok resource response

### ok

    public final Response.Render ok(Locale locale)

  Renders the template.

  Parameters:
    `locale` - the locale
  Returns:
    the ok resource response

### ok

    public final Response.Render ok(Map<String,?> parameters)

  Renders the template and set the response on the current `MimeContext`.

  Parameters:
    `parameters` - the parameters
  Returns:
    the ok resource response

### ok

    public final Response.Render ok(Map<String,?> parameters,
                                    Locale locale)

  Renders the template.

  Parameters:
    `parameters` - the parameters
    `locale` - the locale
  Returns:
    the ok resource response

### notFound

    public final Response.Render notFound()

  Renders the template.

  Returns:
    the not found resource response

### notFound

    public final Response.Render notFound(Locale locale)

  Renders the template.

  Parameters:
    `locale` - the locale
  Returns:
    the not found resource response

### notFound

    public final Response.Render notFound(Map<String,?> parameters)

  Renders the template.

  Parameters:
    `parameters` - the parameters
  Returns:
    the not found resource response

### notFound

    public final Response.Render notFound(Map<String,?> parameters,
                                          Locale locale)

  Renders the template.

  Parameters:
    `parameters` - the parameters
    `locale` - the locale
  Returns:
    the not found resource response

### renderTo

    public <A extends Appendable> A renderTo(A appendable)
                                  throws TemplateExecutionException,
                                         UndeclaredIOException

  Renders the template to the specified appendable.

  Parameters:
    `appendable` - the appendable
  Throws:
    `TemplateExecutionException` - any execution exception
    `UndeclaredIOException` - any io exception

### renderTo

    public <A extends Appendable> A renderTo(A appendable,
                                             Locale locale)
                                  throws TemplateExecutionException,
                                         UndeclaredIOException

  Renders the template to the specified appendable.

  Parameters:
    `appendable` - the appendable
    `locale` - the locale
  Throws:
    `TemplateExecutionException` - any execution exception
    `UndeclaredIOException` - any io exception

### renderTo

    public <A extends Appendable> A renderTo(A appendable,
                                             Map<String,?> parameters)
                                  throws TemplateExecutionException,
                                         UndeclaredIOException

  Renders the template to the specified appendable.

  Parameters:
    `appendable` - the appendable
    `parameters` - the attributes
  Throws:
    `TemplateExecutionException` - any execution exception
    `UndeclaredIOException` - any io exception

### renderTo

    public void renderTo(Stream.Char printer)
                  throws TemplateExecutionException,
                         UndeclaredIOException

  Renders the template to the specified printer.

  Parameters:
    `printer` - the printer
  Throws:
    `TemplateExecutionException` - any execution exception
    `UndeclaredIOException` - any io exception

### renderTo

    public void renderTo(Stream.Char printer,
                         Locale locale)
                  throws TemplateExecutionException,
                         UndeclaredIOException

  Renders the template to the specified printer.

  Parameters:
    `printer` - the printer
    `locale` - the locale
  Throws:
    `TemplateExecutionException` - any execution exception
    `UndeclaredIOException` - any io exception

### renderTo

    public void renderTo(Stream.Char printer,
                         Map<String,?> parameters)
                  throws TemplateExecutionException,
                         UndeclaredIOException

  Renders the template to the specified printer.

  Parameters:
    `printer` - the printer
    `parameters` - the attributes
  Throws:
    `TemplateExecutionException` - any execution exception
    `UndeclaredIOException` - any io exception

### with

    public Template.Builder with()

  Returns a builder to further customize the template rendering.

  Returns:
    a new builder instance

### with

    public Template.Builder with(Map<String,?> parameters)

  Returns a builder to further customize the template rendering.

  Returns:
    a new builder instance

### with

    public Template.Builder with(Locale locale)

  Returns a builder to further customize the template rendering.

  Returns:
    a new builder instance

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2013 eXo Platform SAS. All Rights Reserved.