Class FreemarkerMixin.Builder
- All Implemented Interfaces:
ViewMixinBuilder<FreemarkerMixin.Builder>
- Direct Known Subclasses:
ConsoleFreemarkerMixin.Builder
- Enclosing class:
- FreemarkerMixin
FreemarkerMixin.
Mirrors FreemarkerDispatcher.Builder's configuration methods on its own surface and
forwards each call into a held FreemarkerDispatcher.Builder (worker-bean
composition). Implements ViewMixinBuilder so basePath(String) and
cacheTemplates(boolean) are guaranteed to transfer to the sibling JSP / Thymeleaf /
Mustache bridge builders.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBuilder()Constructor — package access forFreemarkerMixin.create(). -
Method Summary
Modifier and TypeMethodDescriptionSets the classpath base path under which template resources are resolved.build()Builds theFreemarkerMixin.cacheTemplates(boolean value) Sets the template-cache flag for the bridge-default configuration.exposeFields(boolean value) Sets whether the bridge-defaultObjectWrapperexposes public fields (not just JavaBean getters) to templates.Reads the current base path setting (test/inspection helper).freemarker.template.ObjectWrapperReads the current object-wrapper override (test/inspection helper).Reads the current template-suffix setting (test/inspection helper).booleanReads the current cache-templates setting (test/inspection helper).booleanReads the current field-exposure setting (test/inspection helper).objectWrapper(freemarker.template.ObjectWrapper value) Sets a fully customObjectWrapperfor the bridge-default configuration, overridingexposeFields(boolean)entirely.templateSuffix(String value) Sets the suffix to append to template names that don't already end with it (idempotent).
-
Constructor Details
-
Builder
protected Builder()Constructor — package access forFreemarkerMixin.create().
-
-
Method Details
-
basePath
Sets the classpath base path under which template resources are resolved.Defaults to
"/". A typical configured value is"/templates/"— the same Spring-Boot-compatible layout convention the sibling JSP / Thymeleaf / Mustache bridges use.- Specified by:
basePathin interfaceViewMixinBuilder<FreemarkerMixin.Builder>- Parameters:
value- The base path.nullor blank values reset to the defaultFreemarkerMixin.DEFAULT_BASE_PATH.- Returns:
- This object.
-
templateSuffix
Sets the suffix to append to template names that don't already end with it (idempotent).Defaults to
""(no implicit suffix — literal template names). Typical configured values are".ftlh"(HTML auto-escape) or".ftl"(no auto-escape).- Parameters:
value- The new suffix.nullresets toFreemarkerMixin.DEFAULT_TEMPLATE_SUFFIX.- Returns:
- This object.
-
cacheTemplates
Sets the template-cache flag for the bridge-default configuration.Defaults to
true(cache forever — production-safe). Setfalseto enable dev hot-reload (FreeMarker re-checks the underlying resource on every render).This flag only affects the bridge-default
Configuration; user-supplied@Bean Configurations are not modified.- Specified by:
cacheTemplatesin interfaceViewMixinBuilder<FreemarkerMixin.Builder>- Parameters:
value- The cache flag.- Returns:
- This object.
-
exposeFields
Sets whether the bridge-defaultObjectWrapperexposes public fields (not just JavaBean getters) to templates.Defaults to
trueso simple view-model DTOs written with public fields and no getters render their field values instead of silently resolving tonull/missing (see the class-level "Public-field DTOs" section). Has no effect onceobjectWrapper(ObjectWrapper)has been called with a non-nullvalue — the explicit wrapper always wins.- Parameters:
value- The field-exposure flag.- Returns:
- This object.
-
objectWrapper
Sets a fully customObjectWrapperfor the bridge-default configuration, overridingexposeFields(boolean)entirely.Escape hatch for consumers who need full control (e.g. a
BeansWrapperwith custom method/property exposure, or a third-party wrapper) without hand-rolling and registering a whole replacementConfigurationbean.- Parameters:
value- The object wrapper.nullreverts to the bridge-builtDefaultObjectWrapper(perexposeFields(boolean)).- Returns:
- This object.
-
getBasePath
Reads the current base path setting (test/inspection helper).- Returns:
- The base path. Never
null.
-
getTemplateSuffix
Reads the current template-suffix setting (test/inspection helper).- Returns:
- The template suffix. Never
null.
-
isCacheTemplates
Reads the current cache-templates setting (test/inspection helper).- Returns:
- The cache flag.
-
isExposeFields
Reads the current field-exposure setting (test/inspection helper).- Returns:
- The field-exposure flag.
-
getObjectWrapper
Reads the current object-wrapper override (test/inspection helper).- Returns:
- The object wrapper override, or
nullif none has been set.
-
build
Builds theFreemarkerMixin.- Returns:
- A new
FreemarkerMixininstance.
-