More compact ftl output

This commit is contained in:
Joseph Garrone 2024-06-12 20:13:44 +02:00
parent e90e003204
commit 2bb27c7642

View File

@ -2,23 +2,16 @@
(()=>{ (()=>{
<#assign pageId="PAGE_ID_xIgLsPgGId9D8e"> <#assign pageId="PAGE_ID_xIgLsPgGId9D8e">
const out = ${ftl_object_to_js_code_declaring_an_object(.data_model, [])?no_esc}; const out = ${ftl_object_to_js_code_declaring_an_object(.data_model, [])?no_esc};
if( out.messagesPerField ){ if( out.messagesPerField ){
var existsError_singleFieldName = out.messagesPerField.existsError;
{ out.messagesPerField.existsError = function (){
for( let i = 0; i < arguments.length; i++ ){
var existsError_singleFieldName = out.messagesPerField.existsError; if( existsError_singleFieldName(arguments[i]) ){
return true;
out.messagesPerField.existsError = function (){
for( let i = 0; i < arguments.length; i++ ){
if( existsError_singleFieldName(arguments[i]) ){
return true;
}
} }
return false; }
}; return false;
};
}
out.messagesPerField.exists = function (fieldName) { out.messagesPerField.exists = function (fieldName) {
return out.messagesPerField.get(fieldName) !== ""; return out.messagesPerField.get(fieldName) !== "";
}; };
@ -33,19 +26,15 @@ if( out.messagesPerField ){
} }
} }
}; };
} }
out.keycloakifyVersion = "KEYCLOAKIFY_VERSION_xEdKd3xEdr"; out.keycloakifyVersion = "KEYCLOAKIFY_VERSION_xEdKd3xEdr";
out.themeVersion = "KEYCLOAKIFY_THEME_VERSION_sIgKd3xEdr3dx"; out.themeVersion = "KEYCLOAKIFY_THEME_VERSION_sIgKd3xEdr3dx";
out.themeType = "KEYCLOAKIFY_THEME_TYPE_dExKd3xEdr"; out.themeType = "KEYCLOAKIFY_THEME_TYPE_dExKd3xEdr";
out.themeName = "KEYCLOAKIFY_THEME_NAME_cXxKd3xEer"; out.themeName = "KEYCLOAKIFY_THEME_NAME_cXxKd3xEer";
out.pageId = "${pageId}"; out.pageId = "${pageId}";
if( out.url && out.url.resourcesPath ){ if( out.url && out.url.resourcesPath ){
out.url.resourcesCommonPath = out.url.resourcesPath + "/" + "RESOURCES_COMMON_cLsLsMrtDkpVv"; out.url.resourcesCommonPath = out.url.resourcesPath + "/" + "RESOURCES_COMMON_cLsLsMrtDkpVv";
} }
<#if profile?? && profile.attributes??> <#if profile?? && profile.attributes??>
out.lOCALIZATION_REALM_OVERRIDES_USER_PROFILE_PROPERTY_KEY_aaGLsPgGIdeeX = { out.lOCALIZATION_REALM_OVERRIDES_USER_PROFILE_PROPERTY_KEY_aaGLsPgGIdeeX = {
<#list profile.attributes as attribute> <#list profile.attributes as attribute>
@ -74,29 +63,20 @@ if( out.url && out.url.resourcesPath ){
</#list> </#list>
}; };
</#if> </#if>
attributes_to_attributesByName: { attributes_to_attributesByName: {
if( !out.profile ){ if( !out.profile ){
break attributes_to_attributesByName; break attributes_to_attributesByName;
} }
if( !out.profile.attributes ){ if( !out.profile.attributes ){
break attributes_to_attributesByName; break attributes_to_attributesByName;
} }
var attributes = out.profile.attributes; var attributes = out.profile.attributes;
delete out.profile.attributes; delete out.profile.attributes;
out.profile.attributesByName = {}; out.profile.attributesByName = {};
attributes.forEach(function(attribute){ attributes.forEach(function(attribute){
out.profile.attributesByName[attribute.name] = attribute; out.profile.attributesByName[attribute.name] = attribute;
}); });
} }
return out; return out;
function decodeHtmlEntities(htmlStr){ function decodeHtmlEntities(htmlStr){
@ -108,7 +88,6 @@ function decodeHtmlEntities(htmlStr){
element.innerHTML = htmlStr; element.innerHTML = htmlStr;
return element.value; return element.value;
} }
})(); })();
<#function ftl_object_to_js_code_declaring_an_object object path> <#function ftl_object_to_js_code_declaring_an_object object path>