Remove syntax error in ftl and make it more directly debugable

This commit is contained in:
garronej
2021-10-11 13:46:47 +02:00
parent 4ad3affadb
commit 637bc75fc2

View File

@ -126,80 +126,83 @@
(()=>{ (()=>{
//Removing all the undefined const nonAutomaticallyConvertible = {
const obj = JSON.parse(JSON.stringify(<@objectToJson object=.data_model depth=0 />)); "messagesPerField": {
//Freemarker values that can't be automatically converted into a JavaScript object. <#assign fieldNames = ["global", "userLabel", "username", "email", "firstName", "lastName", "password", "password-confirm"]>
Object.deepAssign(
obj,
{
"messagesPerField": {
<#assign fieldNames = ["global", "userLabel", "username", "email", "firstName", "lastName", "password", "password-confirm"]> <#attempt>
<#list profile.attributes as attribute>
<#assign fieldNames += [attribute.name]>
</#list>
<#recover>
</#attempt>
<#attempt> "printIfExists": function (fieldName, x) {
<#list profile.attributes as attribute> <#list fieldNames as fieldName>
<#assign fieldNames += [attribute.name]> if(fieldName === "${fieldName}" ){
</#list> <#attempt>
<#recover> return "${messagesPerField.printIfExists(fieldName,'1')}" ? x : undefined;
</#attempt> <#recover>
</#attempt>
"printIfExists": function (fieldName, x) { }
<#list fieldNames as fieldName> </#list>
if(fieldName === "${fieldName}" ){ throw new Error("There is no " + fieldName + " field");
<#attempt>
return "${messagesPerField.printIfExists(fieldName,'1')}" ? x : undefined;
<#recover>
</#attempt>
}
</#list>
throw new Error("There is no " + fieldName " field");
},
"existsError": function (fieldName) {
<#list fieldNames as fieldName>
if(fieldName === "${fieldName}" ){
<#attempt>
return <#if messagesPerField.existsError('${fieldName}')>true<#else>false</#if>;
<#recover>
</#attempt>
}
</#list>
throw new Error("There is no " + fieldName " field");
},
"get": function (fieldName) {
<#list fieldNames as fieldName>
if(fieldName === "${fieldName}" ){
<#attempt>
<#if messagesPerField.existsError('${fieldName}')>
if(fieldName === "${fieldName}" ){
return "${messagesPerField.get('${fieldName}')?no_esc}";
}
</#if>
<#recover>
</#attempt>
}
</#list>
throw new Error("There is no " + fieldName " field");
},
"exists": function (fieldName) {
<#list fieldNames as fieldName>
if(fieldName === "${fieldName}" ){
<#attempt>
return <#if messagesPerField.exists('${fieldName}')>true<#else>false</#if>;
<#recover>
</#attempt>
}
</#list>
throw new Error("There is no " + fieldName " field");
}
}, },
"msg": function(){ throw new Error("use import { useKcMessage } from 'keycloakify'"); }, "existsError": function (fieldName) {
"advancedMsg": function(){ throw new Error("use import { useKcMessage } from 'keycloakify'"); } <#list fieldNames as fieldName>
} if(fieldName === "${fieldName}" ){
<#attempt>
return <#if messagesPerField.existsError('${fieldName}')>true<#else>false</#if>;
<#recover>
</#attempt>
}
</#list>
throw new Error("There is no " + fieldName + " field");
},
"get": function (fieldName) {
<#list fieldNames as fieldName>
if(fieldName === "${fieldName}" ){
<#attempt>
<#if messagesPerField.existsError('${fieldName}')>
return "${messagesPerField.get('${fieldName}')?no_esc}";
</#if>
<#recover>
</#attempt>
}
</#list>
throw new Error("There is no " + fieldName + " field");
},
"exists": function (fieldName) {
<#list fieldNames as fieldName>
if(fieldName === "${fieldName}" ){
<#attempt>
return <#if messagesPerField.exists('${fieldName}')>true<#else>false</#if>;
<#recover>
</#attempt>
}
</#list>
throw new Error("There is no " + fieldName + " field");
}
},
"msg": function(){ throw new Error("use import { useKcMessage } from 'keycloakify'"); },
"advancedMsg": function(){ throw new Error("use import { useKcMessage } from 'keycloakify'"); }
};
const out = {};
Object.deepAssign(
out,
//Removing all the undefined
JSON.parse(JSON.stringify(<@objectToJson object=.data_model depth=0 />))
); );
return obj; Object.deepAssign(
out,
nonAutomaticallyConvertible
);
return out;
})() })()
</script> </script>