casid / jte-intellij

IntelliJ plugin for jte template files.
https://github.com/casid/jte
Apache License 2.0
21 stars 4 forks source link

Plugin requires named parameter template calls #25

Open devxzero opened 1 year ago

devxzero commented 1 year ago

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

casid commented 1 year ago

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.