Class PathGlobMatcher


  • public class PathGlobMatcher
    extends TemplateSourceMatcher
    Matches the whole template source name (also known as template source path) with the given glob. Note that the template source name is relative to the template storage root defined by the TemplateLoader; it's not the full path of a file on the file system.

    This glob implementation recognizes ** (Ant-style directory wildcard) among others. For more details see StringUtil.globToRegularExpression(String, boolean).

    About the usage of / (slash):

    • You aren't allowed to start the glob with /, because template names (template paths) never start with it.
    • Future FreeMarker versions (compared to 2.3.24) might will support importing whole directories. Directory paths in FreeMarker should end with /. Hence, foo/bar refers to the file {bar}, while foo/bar/ refers to the {bar} directory.

    By default the glob is case sensitive, but this can be changed with setCaseInsensitive(boolean) (or caseInsensitive(boolean)).

    Since:
    2.3.24
    • Method Detail

      • matches

        public boolean matches​(java.lang.String sourceName,
                               java.lang.Object templateSource)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • isCaseInsensitive

        public boolean isCaseInsensitive()
      • setCaseInsensitive

        public void setCaseInsensitive​(boolean caseInsensitive)
        Sets if the matching will be case insensitive (UNICODE compliant); default is false.