Class SkipFirstMethodModel

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

    public class SkipFirstMethodModel
    extends java.lang.Object
    implements freemarker.template.TemplateMethodModel
    Template model that enables template writer to skip first occurence of a given argument.

    Example:

     <#if condition>
     $skip('AND') something
     </#if>
     $skip('AND') something more
     

    The first time the method is called, nothing is output, the next call will output 'AND' (without quotes). In this case that means that 'AND' will only be output if the condition is true, resulting in either: "something AND something more" or just "something more".

    Calls to skip can optionally be scoped to provide more control. Example:

     <#if condition>
     $skip('AND', 'scope1') something
     </#if>
     $skip('AND', 'scope1') something more
     OR
     <#if another condition>
     $skip('AND', 'scope2') something else
     </#if>
     $skip('AND', 'scope2') more something else
     

    This effectively separates concerns for the first two calls and the last two calls, resulting in the possible outcomes:

    • something AND something more OR something else AND more something else
    • something more OR something else AND more something else
    • something AND something more OR more something else
    • something more OR more something else
    • Field Summary

      • Fields inherited from interface freemarker.template.TemplateModel

        NOTHING
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object exec​(java.util.List arguments)  
      void reset()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SkipFirstMethodModel

        public SkipFirstMethodModel()
    • Method Detail

      • exec

        public java.lang.Object exec​(java.util.List arguments)
                              throws freemarker.template.TemplateModelException
        Specified by:
        exec in interface freemarker.template.TemplateMethodModel
        Throws:
        freemarker.template.TemplateModelException
      • reset

        public void reset()