Package io.quarkus.qute
Interface SectionHelperFactory<T extends SectionHelper>
-
- All Known Implementing Classes:
EvalSectionHelper.Factory,IfSectionHelper.Factory,IncludeSectionHelper.Factory,InsertSectionHelper.Factory,LoopSectionHelper.Factory,SetSectionHelper.Factory,UserTagSectionHelper.Factory,WhenSectionHelper.Factory,WithSectionHelper.Factory
public interface SectionHelperFactory<T extends SectionHelper>Factory to create a newSectionHelperbased on theSectionInitContextImpl.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceSectionHelperFactory.BlockInfostatic classSectionHelperFactory.ParametersInfostatic interfaceSectionHelperFactory.ParserDelegatestatic interfaceSectionHelperFactory.SectionInitContextSection initialization context.
-
Field Summary
Fields Modifier and Type Field Description static StringMAIN_BLOCK_NAME
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default booleancacheFactoryConfig()If the return value istruethengetDefaultAliases(),getParameters()andgetBlockLabels()methods are called exactly once and the results are cached when the factory is being registered.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.default List<String>getDefaultAliases()default SectionHelperFactory.ParametersInfogetParameters()A factory may definefactory parametersfor the start tag of any section block.Tinitialize(SectionHelperFactory.SectionInitContext context)default ScopeinitializeBlock(Scope outerScope, SectionHelperFactory.BlockInfo block)Initialize a section block.default booleantreatUnknownSectionsAsBlocks()By default, all unknown nested sections are ignored, ie.
-
-
-
Field Detail
-
MAIN_BLOCK_NAME
static final String MAIN_BLOCK_NAME
- See Also:
- Constant Field Values
-
-
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 definefactory parametersfor the start tag of any section block. A factoryParameterhas 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:- Named actual params are processed first and the relevant values are assigned, e.g. the param with name
agehas the value10, - 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,
- Otherwise, the values are set according to position but params with no default value take precedence.
- 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()
- Named actual params are processed first and the relevant values are assigned, e.g. the param with name
-
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 istruethengetDefaultAliases(),getParameters()andgetBlockLabels()methods are called exactly once and the results are cached when the factory is being registered.- Returns:
truethe config should be cached,falseotherwise
-
treatUnknownSectionsAsBlocks
default boolean treatUnknownSectionsAsBlocks()
By default, all unknown nested sections are ignored, ie. sections with labels not present in thegetBlockLabels(). However, sometimes it might be useful to treat such sections as blocks. SeeIncludeSectionHelperfor an example.- Returns:
- true if unknown sections should not be ignored
-
initialize
T initialize(SectionHelperFactory.SectionInitContext context)
- Parameters:
context-- Returns:
- a new helper instance
-
initializeBlock
default Scope initializeBlock(Scope outerScope, SectionHelperFactory.BlockInfo block)
Initialize a section block.- Returns:
- a new scope if this section introduces a new scope, or the outer scope
- See Also:
SectionHelperFactory.BlockInfo.addExpression(String, String)
-
-