Class HandlebarsTemplateParams

java.lang.Object
com.jalios.jcms.uicomponent.handlebars.HandlebarsTemplateParams

public class HandlebarsTemplateParams extends Object
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
  • Method Details

    • getParams

      public Map<String,Object> getParams()
      Returns the parameters map used by the Handlebars template.
      Returns:
      a map of parameter keys and values
      Since:
      jcms-11.0.0
    • getLang

      public String getLang()
      Returns the language code used for localization.
      Returns:
      the language code (e.g., "en", "fr")
      Since:
      jcms-11.0.0
    • toJson

      public String 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 feature
      request - 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

      public static HandlebarsTemplateParams.Builder builder(String lang)
      Creates a new HandlebarsTemplateParams.Builder instance for the given language.
      Parameters:
      lang - the language code (must not be null)
      Returns:
      a new Builder instance
      Since:
      jcms-11.0.0