in freemarker-core/src/main/java/freemarker/core/TemplateConfiguration.java [302:408]
public void apply(Template template) {
Configuration cfg = getNonNullParentConfiguration();
if (template.getConfiguration() != cfg) {
// This is actually not a problem right now, but for future BC we enforce this.
throw new IllegalArgumentException(
"The argument Template doesn't belong to the same Configuration as the TemplateConfiguration");
}
if (isAPIBuiltinEnabledSet() && !template.isAPIBuiltinEnabledSet()) {
template.setAPIBuiltinEnabled(isAPIBuiltinEnabled());
}
if (isArithmeticEngineSet() && !template.isArithmeticEngineSet()) {
template.setArithmeticEngine(getArithmeticEngine());
}
if (isAutoFlushSet() && !template.isAutoFlushSet()) {
template.setAutoFlush(getAutoFlush());
}
if (isBooleanFormatSet() && !template.isBooleanFormatSet()) {
template.setBooleanFormat(getBooleanFormat());
}
if (isClassicCompatibleSet() && !template.isClassicCompatibleSet()) {
template.setClassicCompatibleAsInt(getClassicCompatibleAsInt());
}
if (isCustomDateFormatsSet()) {
template.setCustomDateFormats(
mergeMaps(getCustomDateFormats(), template.getCustomDateFormatsWithoutFallback(), false));
}
if (isCustomNumberFormatsSet()) {
template.setCustomNumberFormats(
mergeMaps(getCustomNumberFormats(), template.getCustomNumberFormatsWithoutFallback(), false));
}
if (isDateFormatSet() && !template.isDateFormatSet()) {
template.setDateFormat(getDateFormat());
}
if (isDateTimeFormatSet() && !template.isDateTimeFormatSet()) {
template.setDateTimeFormat(getDateTimeFormat());
}
if (isCFormatSet() && !template.isCFormatSet()) {
template.setCFormat(getCFormat());
}
if (isEncodingSet() && template.getEncoding() == null) {
template.setEncoding(getEncoding());
}
if (isLocaleSet() && !template.isLocaleSet()) {
template.setLocale(getLocale());
}
if (isLogTemplateExceptionsSet() && !template.isLogTemplateExceptionsSet()) {
template.setLogTemplateExceptions(getLogTemplateExceptions());
}
if (isWrapUncheckedExceptionsSet() && !template.isWrapUncheckedExceptionsSet()) {
template.setWrapUncheckedExceptions(getWrapUncheckedExceptions());
}
if (isNewBuiltinClassResolverSet() && !template.isNewBuiltinClassResolverSet()) {
template.setNewBuiltinClassResolver(getNewBuiltinClassResolver());
}
if (isTruncateBuiltinAlgorithmSet() && !template.isTruncateBuiltinAlgorithmSet()) {
template.setTruncateBuiltinAlgorithm(getTruncateBuiltinAlgorithm());
}
if (isNumberFormatSet() && !template.isNumberFormatSet()) {
template.setNumberFormat(getNumberFormat());
}
if (isObjectWrapperSet() && !template.isObjectWrapperSet()) {
template.setObjectWrapper(getObjectWrapper());
}
if (isOutputEncodingSet() && !template.isOutputEncodingSet()) {
template.setOutputEncoding(getOutputEncoding());
}
if (isShowErrorTipsSet() && !template.isShowErrorTipsSet()) {
template.setShowErrorTips(getShowErrorTips());
}
if (isSQLDateAndTimeTimeZoneSet() && !template.isSQLDateAndTimeTimeZoneSet()) {
template.setSQLDateAndTimeTimeZone(getSQLDateAndTimeTimeZone());
}
if (isTemplateExceptionHandlerSet() && !template.isTemplateExceptionHandlerSet()) {
template.setTemplateExceptionHandler(getTemplateExceptionHandler());
}
if (isAttemptExceptionReporterSet() && !template.isAttemptExceptionReporterSet()) {
template.setAttemptExceptionReporter(getAttemptExceptionReporter());
}
if (isTimeFormatSet() && !template.isTimeFormatSet()) {
template.setTimeFormat(getTimeFormat());
}
if (isTimeZoneSet() && !template.isTimeZoneSet()) {
template.setTimeZone(getTimeZone());
}
if (isURLEscapingCharsetSet() && !template.isURLEscapingCharsetSet()) {
template.setURLEscapingCharset(getURLEscapingCharset());
}
if (isLazyImportsSet() && !template.isLazyImportsSet()) {
template.setLazyImports(getLazyImports());
}
if (isLazyAutoImportsSet() && !template.isLazyAutoImportsSet()) {
template.setLazyAutoImports(getLazyAutoImports());
}
if (isAutoImportsSet()) {
// Regarding the order of the maps in the merge:
// - Existing template-level imports have precedence over those coming from the TC (just as with the others
// apply()-ed settings), thus for clashing import prefixes they must win.
// - Template-level imports count as more specific, and so come after the more generic ones from TC.
template.setAutoImports(mergeMaps(getAutoImports(), template.getAutoImportsWithoutFallback(), true));
}
if (isAutoIncludesSet()) {
template.setAutoIncludes(mergeLists(getAutoIncludes(), template.getAutoIncludesWithoutFallback()));
}
copyDirectCustomAttributes(template, false);
}