Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build-time validation of Qute templates #6391

Open
gunnarmorling opened this issue Jan 3, 2020 · 3 comments
Open

Build-time validation of Qute templates #6391

gunnarmorling opened this issue Jan 3, 2020 · 3 comments

Comments

@gunnarmorling
Copy link
Collaborator

@gunnarmorling gunnarmorling commented Jan 3, 2020

I was expecting that an invalid reference in a Qute template (e.g. typo in variable name) would raise an error upon mvn clean package, but that's not the case. Is this planned for the future?

@mkouba

This comment has been minimized.

Copy link
Contributor

@mkouba mkouba commented Jan 3, 2020

Expressions are only validated if "parameter declarations" are used in a template, see https://quarkus.io/guides/qute-reference#parameter-declarations for more information. Otherwise it wouldn't be possible e.g. to connect an expression with a type. In other words, a template without param declarations does not know anything about the data that will be available at runtime.

@gunnarmorling

This comment has been minimized.

Copy link
Collaborator Author

@gunnarmorling gunnarmorling commented Jan 3, 2020

Here's an idea: how about collecting implicitly declared parameters by statically analysing the names passed to the data() method in the byte code? It wouldn't be 100% safe as names might be generated dynamically, but most of the times I'd expect this to be invoked with string literals that can be obtained quite easily from class files.

@mkouba

This comment has been minimized.

Copy link
Contributor

@mkouba mkouba commented Jan 6, 2020

Unfortunately, we don't have the tools (in quarkus API/jandex) to collect this information yet. And what's more important - a user can pass different objects as data for the same template. E.g. there could be a template My name is {person.name} and you can pass a Person POJO or a javax.json.JsonObject with a data() method. That's why parameter declarations are necessary if you need to validate the expressions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.