Open NicolasCW opened 1 month ago
Thank you for reporting the issue.
Unfortunately, this is not a trivial problem. In theory, we could check the template calls and determine the param type by values passed to these calls. However, templates are usually implemented first, and there are no calls at this moment, so we wouldn't be able to determine the type.
A better, IMHO, solution would be to add information about the type in the parameter hint, for example:
<template data-sly-template.itemtemplate="${@ item='com.example.Approval'}">
${item.dateApproval}
</template>
The problem is that this custom solution ties the code with the plugin, and some programmers may be against it. Also, there must be a way to make it compatible with usual hints, for example:
<template data-sly-template.itemtemplate="${@ item='Approval item'}">
${item.dateApproval}
</template>
A solution to this would be to parse any non-simple (with package) class name and assume the first found class name is the required type, for example:
<template data-sly-template.itemtemplate="${@ item='Approval item. Must be of com.example.Approval type.'}">
${item.dateApproval}
</template>
The problem would appear if there were two class names and the second would be the param class name, for example:
<template data-sly-template.itemtemplate="${@ item='Approval item returned from com.example.Project.getApproval(). Must be of com.example.Approval type.'}">
${item.dateApproval}
</template>
To solve this, it should be possible to point the type explicitly, for example, by wrapping it into brackets:
<template data-sly-template.itemtemplate="${@ item='Approval item returned from com.example.Project.getApproval(). Must be of [com.example.Approval] type.'}">
${item.dateApproval}
</template>
What do you think? I also encourage others to comment.
The first solution seems to be ok for me. The plugin will try to bind the template with the class in comment and not if it's impossible to find the class, and so in that last cast, it will be the same as now.
I think that we should go with mixing two solutions:
item = 'com.example.Approval'
), then it is considered a parameter typeitem = 'Approval item returned from com.example.Project.getApproval(). Must be of [com.example.Approval] type.'
)This would be great, and is a feature I would use constantly! I think the mixing of these two solutions would provide great flexibility.
It is not possible to use completion for template files. This is a disadvantage when using a lot of templates in the html of components.
Approval.java
approval.html
commonTemplate.html
In the file commonTemplate.html, the completion is not working.