View Javadoc

1   package com.atlassian.plugin.web.renderer;
2   
3   import com.atlassian.plugin.Plugin;
4   
5   import java.io.IOException;
6   import java.io.Writer;
7   import java.util.Map;
8   
9   /**
10   * This interface allows the plugin system to be extended by adding new
11   * renderers for new markup formats. Currently the atlassian-template-renderer
12   * project provides a velocity implementation.
13   *
14   * @see {@link com.atlassian.plugin.web.descriptors.WebPanelRendererModuleDescriptor#getModule()}
15   * @since   2.5.0
16   */
17  public interface WebPanelRenderer
18  {
19      /**
20       * @return the name of the resource type supported by this renderer. {@code <resource>} elements defined in plugin
21       * descriptors to be rendered by this renderer should specify this String as their {@code type} attribute.
22       */
23      String getResourceType();
24  
25      /**
26       * Renders the template to the writer.
27       *
28       * @param templateName file name of the template to render
29       * @param plugin the context plugin. Used, for example, to resolve templates and other resources from the classpath
30       * via {@link Plugin#getClassLoader()}
31       * @param context Map of objects to make available in the template rendering process
32       * @param writer where to write the rendered template
33       * @throws RendererException thrown if there is an internal exception when rendering the template
34       * @throws java.io.IOException thrown if there is a problem reading the template file or writing to the writer
35       */
36      void render(String templateName, Plugin plugin, Map<String, Object> context, Writer writer)
37          throws RendererException, IOException;
38  
39      /**
40       * Renders the {@code fragment} using the given context and adding {@code I18nResolver} and {@code
41       * WebResourceManager}.
42       *
43       * @param fragment template fragment to render
44       * @param plugin the context plugin. Used, for example, to resolve templates and other resources from the classpath
45       * via {@link Plugin#getClassLoader()}
46       * @param context Map of objects to make available in the template rendering process
47       * @return rendered template
48       * @throws RendererException thrown if there is an internal exception when rendering the template
49       */
50      String renderFragment(String fragment, Plugin plugin, Map<String, Object> context) throws RendererException;
51  }