jte-intellij icon indicating copy to clipboard operation
jte-intellij copied to clipboard

Plugin requires named parameter template calls

Open devxzero opened this issue 2 years ago • 2 comments

I just tried JTE for the first time. Great project!

But I'm not sure if I'm overlooking something, but the plugin seems to require named parameters when calling a template with arguments, even though JTE itself compiles fine with just parameter order instead of named parameters.

The JTE documentation does mention in https://github.com/casid/jte/blob/main/DOCUMENTATION.md

If you don't want to depend on the parameter order, you can explicitly name parameters when calling the template (this is what the IntelliJ plugin suggests by default).

But in my situation, it's not just a suggestion of the plugin, it's a requirement of the plugin. So it shows an error if parameter order is used instead.

Example

src/main/jte/component1.jte:

@param String title
@param String componentContent

<div>Component: ${title}</div>
<div>Content: ${componentContent}</div>

src/main/jte/test/jte:

<html>
    <body>
        <h1>Page</h1>
        @template.component1("Hello world", "Content")
    </body>
</html>

This will show the error:

Missing required parameters: title, componentContent

jte-intellij-error-highlight

devxzero avatar Feb 18 '23 23:02 devxzero

Thank you for the heads up!

Yes, this is indeed a bug, where the plugin doesn't 100% follow the jte documentation.

So far, I didn't have problems with it, since the plugin generates parameter names for template calls anyways by default. In the projects I'm using jte we have the convention to always use paramter names (so for us it's almost a feature, rather than a bug, heh :-))

So far I haven't found time to look into it - the parameter parts are a bit hacky already.

casid avatar Feb 19 '23 18:02 casid

I am experiencing the exact same issue. It looks weird at first when the JTE docs says named parameter are not required.

laurentpellegrino avatar Jan 11 '25 22:01 laurentpellegrino