Class PebbleViewsRenderer<T,R>

java.lang.Object
io.micronaut.views.pebble.PebbleViewsRenderer<T,R>
Type Parameters:
T - The model type
R - The request type
All Implemented Interfaces:
io.micronaut.core.order.Ordered, ViewsRenderer<T,R>

@Singleton @Requires(property="micronaut.views.pebble.enabled",notEquals="false") @Requires(classes=io.pebbletemplates.pebble.PebbleEngine.class) public class PebbleViewsRenderer<T,R> extends Object implements ViewsRenderer<T,R>
Renders Views with Pebble.
Since:
2.2.0
Author:
Ecmel Ercan
See Also:
  • Field Summary

    Fields inherited from interface io.micronaut.core.order.Ordered

    HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
  • Constructor Summary

    Constructors
    Constructor
    Description
    PebbleViewsRenderer(io.pebbletemplates.pebble.PebbleEngine engine, io.micronaut.core.util.LocaleResolver<R> httpLocaleResolver)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    exists(@NonNull String name)
     
    @NonNull io.micronaut.core.io.Writable
    render(@NonNull String name, T data, R request)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.micronaut.core.order.Ordered

    getOrder
  • Constructor Details

    • PebbleViewsRenderer

      public PebbleViewsRenderer(io.pebbletemplates.pebble.PebbleEngine engine, io.micronaut.core.util.LocaleResolver<R> httpLocaleResolver)
      Parameters:
      engine - Pebble Engine
      httpLocaleResolver - The locale resolver
  • Method Details

    • render

      @NonNull public @NonNull io.micronaut.core.io.Writable render(@NonNull @NonNull String name, @Nullable T data, @Nullable R request)
      Specified by:
      render in interface ViewsRenderer<T,R>
      Parameters:
      name - view name to be rendered
      data - response body to render it with a view
      request - HTTP request
      Returns:
      A writable where the view will be written to.
    • exists

      public boolean exists(@NonNull @NonNull String name)
      Specified by:
      exists in interface ViewsRenderer<T,R>
      Parameters:
      name - view name to be rendered
      Returns:
      true if a template can be found for the supplied view name.