Class HandlebarsViewsRenderer<T,R>

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

@Requires(property="micronaut.views.handlebars.enabled",notEquals="false") @Requires(classes=com.github.jknack.handlebars.Handlebars.class) @Singleton public class HandlebarsViewsRenderer<T,R> extends Object implements ViewsRenderer<T,R>
Renders Views with Handlebars.java.
Since:
1.0
Author:
Sergio del Amo
See Also:
  • Field Details

    • viewsConfiguration

      protected final ViewsConfiguration viewsConfiguration
    • resourceLoader

      protected final io.micronaut.core.io.ResourceLoader resourceLoader
    • handlebarsViewsRendererConfiguration

      protected HandlebarsViewsRendererConfiguration handlebarsViewsRendererConfiguration
    • handlebars

      protected com.github.jknack.handlebars.Handlebars handlebars
    • folder

      protected String folder
  • Constructor Details

    • HandlebarsViewsRenderer

      @Inject public HandlebarsViewsRenderer(ViewsConfiguration viewsConfiguration, io.micronaut.core.io.scan.ClassPathResourceLoader resourceLoader, HandlebarsViewsRendererConfiguration handlebarsViewsRendererConfiguration, com.github.jknack.handlebars.Handlebars handlebars)
      Parameters:
      viewsConfiguration - Views Configuration
      resourceLoader - Resource Loader
      handlebarsViewsRendererConfiguration - Handlebars ViewRenderer Configuration.
      handlebars - Handlebars Engine
  • Method Details

    • render

      @NonNull public @NonNull io.micronaut.core.io.Writable render(@NonNull @NonNull String viewName, @Nullable T data, @Nullable R request)
      Specified by:
      render in interface ViewsRenderer<T,R>
      Parameters:
      viewName - 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 viewName)
      Specified by:
      exists in interface ViewsRenderer<T,R>
      Parameters:
      viewName - view name to be rendered
      Returns:
      true if a template can be found for the supplied view name.