Interface SectionHelperFactory<T extends SectionHelper>

    • Method Detail

      • getDefaultAliases

        default List<String> getDefaultAliases()
        Returns:
        the list of default aliases used to match the helper
        See Also:
        cacheFactoryConfig()
      • getParameters

        default SectionHelperFactory.ParametersInfo getParameters()
        A factory may define factory parameters for the start tag of any section block. A factory Parameter has a name and optional default value. The default value is automatically assigned if no other value is set by a parser. A parameter may be optional. A non-optional parameter that has no value assigned results in a parser error.

        A section block in a template defines the actual parameters:

         {! The value is "item.isActive". The name is not defined. !}
         {#if item.isActive}{/}
        
         {! The name is "age" and the value is "10". !}
         {#let age=10}{/}
         
        The actual parameters are parsed taking the factory parameters into account:
        1. Named actual params are processed first and the relevant values are assigned, e.g. the param with name age has the value 10,
        2. Then, if the number of actual params is greater or equals to the number of factory params the values are set according to position of factory params,
        3. Otherwise, the values are set according to position but params with no default value take precedence.
        4. Finally, all unset parameters that define a default value are initialized with the default value.
        Returns:
        the factory parameters
        See Also:
        cacheFactoryConfig(), SectionHelperFactory.BlockInfo.getParameters()
      • getBlockLabels

        default List<String> getBlockLabels()
        A nested section tag that matches a name of a block will be added as a block to the current section.
        Returns:
        the list of block labels
        See Also:
        cacheFactoryConfig()
      • cacheFactoryConfig

        default boolean cacheFactoryConfig()
        If the return value is true then getDefaultAliases(), getParameters() and getBlockLabels() methods are called exactly once and the results are cached when the factory is being registered.
        Returns:
        true the config should be cached, false otherwise
      • treatUnknownSectionsAsBlocks

        default boolean treatUnknownSectionsAsBlocks()
        By default, all unknown nested sections are ignored, ie. sections with labels not present in the getBlockLabels(). However, sometimes it might be useful to treat such sections as blocks. See IncludeSectionHelper for an example.
        Returns:
        true if unknown sections should not be ignored
      • initialize

        T initialize​(SectionHelperFactory.SectionInitContext context)
        Initialize a new helper instance for a specific section node in a template.
        Parameters:
        context -
        Returns:
        a new helper instance