Class I18nStringTemplateModel

  • All Implemented Interfaces:
    freemarker.template.TemplateMethodModel, freemarker.template.TemplateMethodModelEx, freemarker.template.TemplateModel, freemarker.template.TemplateScalarModel

    public class I18nStringTemplateModel
    extends Object
    implements freemarker.template.TemplateMethodModelEx, freemarker.template.TemplateScalarModel
    A Freemarker representation of a text string. Because it implements TemplateScalarModel, you can use it as a string value. And because it implements TemplateMethodModel, you can pass arguments to it for formatting. So if the string is "His name is {0}!", then these references could be used: ${string} ==> "His name is {0}!" ${string("Bozo")} ==> "His name is Bozo!" Note that the format of the message is determined by java.text.MessageFormat, so argument indices start at 0 and you can escape a substring by wrapping it in apostrophes.
    • Constructor Detail

      • I18nStringTemplateModel

        public I18nStringTemplateModel​(String key,
                                       String textString)
    • Method Detail

      • getAsString

        public String getAsString()
                           throws freemarker.template.TemplateModelException
        Specified by:
        getAsString in interface freemarker.template.TemplateScalarModel
        Throws:
        freemarker.template.TemplateModelException
      • exec

        public Object exec​(List args)
                    throws freemarker.template.TemplateModelException
        Specified by:
        exec in interface freemarker.template.TemplateMethodModel
        Specified by:
        exec in interface freemarker.template.TemplateMethodModelEx
        Throws:
        freemarker.template.TemplateModelException