Package io.wcm.wcm.commons.util
Class Template
java.lang.Object
io.wcm.wcm.commons.util.Template
Template utility methods
-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable TemplatePathInfoforPage(@NotNull com.day.cq.wcm.api.Page page, @NotNull TemplatePathInfo @NotNull ... templates) Lookup template for given page.static <E extends Enum<E> & TemplatePathInfo>
@Nullable TemplatePathInfoLookup template for given page.static @Nullable TemplatePathInfoforTemplatePath(@NotNull String templatePath, @NotNull TemplatePathInfo @NotNull ... templates) Lookup a template by the given template path.static <E extends Enum<E> & TemplatePathInfo>
@Nullable TemplatePathInfoforTemplatePath(@NotNull String templatePath, @NotNull Class<E> @NotNull ... templateEnums) Lookup a template by the given template path.static @Nullable StringgetResourceTypeFromTemplatePath(@NotNull String templatePath) Gets the resource type for a given template path.static booleanis(@NotNull com.day.cq.wcm.api.Page page, @NotNull TemplatePathInfo @NotNull ... templates) Checks if the given page uses a specific template.static booleanChecks if the given page uses a specific template.
-
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
- Given a template path is
-
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 pagetemplates- 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 pagetemplatePaths- 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 templatetemplates- Templates- Returns:
- The
TemplatePathInfoinstance 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 templatetemplateEnums- Templates- Returns:
- The
TemplatePathInfoinstance 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- Pagetemplates- Templates- Returns:
- The
TemplatePathInfoinstance 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- PagetemplateEnums- Templates- Returns:
- The
TemplatePathInfoinstance or null for unknown template paths
-