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

docs: multi-line import example for page directive #464

Merged
merged 3 commits into from
Sep 11, 2024

Conversation

scscgit
Copy link
Contributor

@scscgit scscgit commented Jul 21, 2024

Documentation didn't cover the case of multiple page imports, which requires semicolons ;. Newbies could try separating them by spaces, which would cause an error Unexpected input: 'com'.

Additionally, I'd like to take this opportunity to ask you to introduce a guideline for optimal code quality. For projects with large number of imports, e.g. when you pass many objects to GSP to work with them, it's beneficial to avoid import being an insanely long line. For version control, you also want to reduce conflicts and individually see git blame for each import. However, to separate lines, you must add an undocumented workaround of a trailing backslash \, otherwise you get an error Unexpected input: '\n'.

Additional questions also arise when you're about to establish a baseline for a new project, which is why I ask you to define a convention here that you expect projects to follow by default, as a de-facto standard. For example:

  1. First import could start on a new line:
import="\
java.awt.*; \
  1. There can be a trailing ; after the last import to reduce diff.
  • However, if we end with ; \ and put " %> at the next line, there is an error Unexpected input: '\r\n'.
  • But if we end the last import without ;, only with \, then it's possible to put " %> as the last line. In this case we can't avoid frequent changes when new imports are added.
  1. We could skip the space before \...

🗒️ The errors are reported under org.codehaus.groovy.control.MultipleCompilationErrorsException: org.grails.gsp.GroovyPagesException: Could not parse script: startup failed.

@CLAassistant
Copy link

CLAassistant commented Jul 21, 2024

CLA assistant check
All committers have signed the CLA.

@scscgit scscgit changed the base branch from 6.2.x to 7.0.x September 11, 2024 13:18
@grails grails deleted a comment from CLAassistant Sep 11, 2024
@jamesfredley jamesfredley self-requested a review September 11, 2024 16:42
@jamesfredley jamesfredley merged commit d005cff into grails:7.0.x Sep 11, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants