Class HandlebarsRenderer

java.lang.Object
com.morpheusdata.views.HandlebarsRenderer
All Implemented Interfaces:
Renderer<com.github.jknack.handlebars.Handlebars>

public class HandlebarsRenderer extends Object implements Renderer<com.github.jknack.handlebars.Handlebars>
HandlebarsRenderer implements the Renderer interface. It uses a Dynamic template loader and Handlebars engine to render templates.
  • Constructor Details

    • HandlebarsRenderer

      public HandlebarsRenderer()
    • HandlebarsRenderer

      public HandlebarsRenderer(String prefix)
    • HandlebarsRenderer

      public HandlebarsRenderer(ClassLoader classLoader)
    • HandlebarsRenderer

      public HandlebarsRenderer(String prefix, ClassLoader classLoader)
    • HandlebarsRenderer

      public HandlebarsRenderer(com.github.jknack.handlebars.Handlebars overrideEngine)
  • Method Details

    • addTemplateLoader

      public void addTemplateLoader(ClassLoader classLoader)
      Add a child first class loader
      Specified by:
      addTemplateLoader in interface Renderer<com.github.jknack.handlebars.Handlebars>
      Parameters:
      classLoader - plugin class loader
    • removeTemplateLoader

      public void removeTemplateLoader(ClassLoader classLoader)
      Remove a class loader
      Specified by:
      removeTemplateLoader in interface Renderer<com.github.jknack.handlebars.Handlebars>
      Parameters:
      classLoader - plugin class loader
    • getTemplateLoaders

      public Iterable<com.github.jknack.handlebars.io.TemplateLoader> getTemplateLoaders()
      Get a list of all template loaders
      Specified by:
      getTemplateLoaders in interface Renderer<com.github.jknack.handlebars.Handlebars>
      Returns:
      list of template loaders
    • render

      public HTMLResponse render(String templateText, ViewModel<?> model)
      Description copied from interface: Renderer
      Given a template and a model, returns a TemplateResponse
      Specified by:
      render in interface Renderer<com.github.jknack.handlebars.Handlebars>
      Parameters:
      templateText - String representation of a template the engine can use.
      model - ViewModel to be passed in with the template
      Returns:
      TemplateResponse
    • renderTemplate

      public HTMLResponse renderTemplate(String location, ViewModel<?> model)
      Description copied from interface: Renderer
      Given a template location and a model, returns a TemplateResponse
      Specified by:
      renderTemplate in interface Renderer<com.github.jknack.handlebars.Handlebars>
      Parameters:
      location - Location where the engine can find the template.
      model - ViewModel to be passed in with the template
      Returns:
      TemplateResponse
    • getEngine

      public com.github.jknack.handlebars.Handlebars getEngine()
      Description copied from interface: Renderer
      The implementation of the actual engine to be used in this renderer
      Specified by:
      getEngine in interface Renderer<com.github.jknack.handlebars.Handlebars>
      Returns:
      engine
    • registerAssetHelper

      public void registerAssetHelper(String pluginName)
      Creates an {{asset}} helper tag that outputs the plugin specific relative url for assets stored in the /src/assets e.g. <link href="{{asset "/custom.css"}}" />
      Parameters:
      pluginName - name of the plugin
      See Also:
    • registerNonceHelper

      public void registerNonceHelper(MorpheusWebRequestService requestService)
    • registerI18nHelper

      public void registerI18nHelper(Plugin plugin, MorpheusContext morpheus)