Interface TextTemplateScript


  • public interface TextTemplateScript
    The API available in template files.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      TextTemplateModel getModel()
      The backing model for this template.
      java.lang.String html​(java.lang.Object value)
      Escapes the toString() value of the given object, by way of HtmlEscapers.
      java.lang.String render​(java.lang.String templateName)
      Renders a nested template inline, using the same model as this template.
      java.lang.String render​(java.util.Map<java.lang.String,​?> model, java.lang.String templateName)
      Renders a nested template inline, with the given model merged with the current template model.
      java.lang.String urlParam​(java.lang.Object value)
      Escapes the toString() value of the given object, by way of UrlEscapers.urlFormParameterEscaper().
      java.lang.String urlPathSegment​(java.lang.Object value)
      Escapes the toString() value of the given object, by way of UrlEscapers.urlPathSegmentEscaper().
    • Method Detail

      • getModel

        TextTemplateModel getModel()
        The backing model for this template.
        Returns:
        The backing model for this template
      • render

        java.lang.String render​(java.lang.String templateName)
                         throws java.lang.Exception
        Renders a nested template inline, using the same model as this template.
        Parameters:
        templateName - The name of the template to render
        Returns:
        An empty string
        Throws:
        java.lang.Exception - if an error occurs compiling/executing the template
        See Also:
        render(java.util.Map, String)
      • render

        java.lang.String render​(java.util.Map<java.lang.String,​?> model,
                                java.lang.String templateName)
                         throws java.lang.Exception
        Renders a nested template inline, with the given model merged with the current template model.

        The nested template will be rendered directly to the underlying buffer; it is not returned from this method. This method returns an empty string so that it can be used in situations where the return value would have been included in the output (e.g. a <?= ?> block).

        The template name is resolved into a template using the same renderer that initiated rendering of this template.

        Parameters:
        model - The model to merge with the current template model
        templateName - The name of the template to render
        Returns:
        The rendered template content
        Throws:
        java.lang.Exception - if an error occurs compiling/executing the template
      • html

        java.lang.String html​(java.lang.Object value)
        Escapes the toString() value of the given object, by way of HtmlEscapers.
        Parameters:
        value - the value to escape
        Returns:
        a minimally escaped version of the given value
      • urlParam

        java.lang.String urlParam​(java.lang.Object value)
        Escapes the toString() value of the given object, by way of UrlEscapers.urlFormParameterEscaper().
        Parameters:
        value - the value to escape
        Returns:
        an escaped version of the given value
      • urlPathSegment

        java.lang.String urlPathSegment​(java.lang.Object value)
        Escapes the toString() value of the given object, by way of UrlEscapers.urlPathSegmentEscaper().
        Parameters:
        value - the value to escape
        Returns:
        an escaped version of the given value