Class Template

java.lang.Object
io.wcm.wcm.commons.util.Template

@ProviderType public final class Template extends Object
Template utility methods
  • Method Details

    • getResourceTypeFromTemplatePath

      @Nullable public static @Nullable String getResourceTypeFromTemplatePath(@NotNull @NotNull String templatePath)
      Gets the resource type for a given template path.

      This is based on the assumption that:

      • Given a template path is /apps/{app_path}/templates/{optional_path}/{template_path}
      • Then the resource path is at {app_path}/components/{optional_path}/page/{template_path}
      Parameters:
      templatePath - Template path
      Returns:
      Resource type path or null if template path did not match expectations
    • is

      public static boolean is(@NotNull @NotNull com.day.cq.wcm.api.Page page, @NotNull @NotNull TemplatePathInfo @NotNull ... templates)
      Checks if the given page uses a specific template.
      Parameters:
      page - AEM page
      templates - Template(s)
      Returns:
      true if the page uses the template
    • is

      public static boolean is(@NotNull @NotNull com.day.cq.wcm.api.Page page, @NotNull @NotNull String @NotNull ... templatePaths)
      Checks if the given page uses a specific template.
      Parameters:
      page - AEM page
      templatePaths - Template path(s)
      Returns:
      true if the page uses the template
    • forTemplatePath

      @Nullable public static @Nullable TemplatePathInfo forTemplatePath(@NotNull @NotNull String templatePath, @NotNull @NotNull TemplatePathInfo @NotNull ... templates)
      Lookup a template by the given template path.
      Parameters:
      templatePath - Path of template
      templates - Templates
      Returns:
      The TemplatePathInfo instance or null for unknown template paths
    • forTemplatePath

      @SafeVarargs @Nullable public static <E extends Enum<E> & TemplatePathInfo> @Nullable TemplatePathInfo forTemplatePath(@NotNull @NotNull String templatePath, @NotNull @NotNull Class<E> @NotNull ... templateEnums)
      Lookup a template by the given template path.
      Type Parameters:
      E - Template enum
      Parameters:
      templatePath - Path of template
      templateEnums - Templates
      Returns:
      The TemplatePathInfo instance or null for unknown template paths
    • forPage

      @Nullable public static @Nullable TemplatePathInfo forPage(@NotNull @NotNull com.day.cq.wcm.api.Page page, @NotNull @NotNull TemplatePathInfo @NotNull ... templates)
      Lookup template for given page.
      Parameters:
      page - Page
      templates - Templates
      Returns:
      The TemplatePathInfo instance or null for unknown template paths
    • forPage

      @SafeVarargs @Nullable public static <E extends Enum<E> & TemplatePathInfo> @Nullable TemplatePathInfo forPage(@NotNull @NotNull com.day.cq.wcm.api.Page page, @NotNull @NotNull Class<E> @NotNull ... templateEnums)
      Lookup template for given page.
      Type Parameters:
      E - Template enum
      Parameters:
      page - Page
      templateEnums - Templates
      Returns:
      The TemplatePathInfo instance or null for unknown template paths