Class HandlebarsTemplateParams
java.lang.Object
com.jalios.jcms.uicomponent.handlebars.HandlebarsTemplateParams
Represents a set of parameters used to render Handlebars templates in JPlatform.
Provides helper methods for localization, icons, and safe JSON serialization.
- Since:
- jcms-11.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class for constructingHandlebarsTemplateParamsinstances.static classContainer class for icon rendering options such as alt text, title, CSS classes, and extra attributes. -
Method Summary
Modifier and TypeMethodDescriptionCreates a newHandlebarsTemplateParams.Builderinstance for the given language.generateHandlebarScript(String feature, javax.servlet.http.HttpServletRequest request) Generates a Handlebars initialization script to be injected into the HTML output.getLang()Returns the language code used for localization.Returns the parameters map used by the Handlebars template.toJson()Converts the internal parameters map into a JSON string.
-
Method Details
-
getParams
Returns the parameters map used by the Handlebars template.- Returns:
- a map of parameter keys and values
- Since:
- jcms-11.0.0
-
getLang
Returns the language code used for localization.- Returns:
- the language code (e.g., "en", "fr")
- Since:
- jcms-11.0.0
-
toJson
Converts the internal parameters map into a JSON string.- Returns:
- a JSON representation of the parameters
- Throws:
RuntimeException- if JSON conversion fails- Since:
- jcms-11.0.0
-
generateHandlebarScript
public String generateHandlebarScript(String feature, javax.servlet.http.HttpServletRequest request) Generates a Handlebars initialization script to be injected into the HTML output. The script safely includes a CSP nonce and registers the parameters under the given feature key.- Parameters:
feature- the name of the Handlebars featurerequest- the current HTTP request, used to retrieve the CSP nonce- Returns:
- a script tag containing the JSON-encoded parameters
- Since:
- jcms-11.0.0
-
builder
Creates a newHandlebarsTemplateParams.Builderinstance for the given language.- Parameters:
lang- the language code (must not be null)- Returns:
- a new Builder instance
- Since:
- jcms-11.0.0
-