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

Use HTML templating in default UIs #15580

Merged
merged 3 commits into from
Sep 5, 2024

Conversation

Kehrlann
Copy link
Contributor

@Kehrlann Kehrlann commented Aug 12, 2024

reviewer: @rwinch

Some notes:

  • I have not updated the tests, they still use string concatenation sometimes. I'd rather not use the templating in the tests themselves. Using text blocks and constants in tests.
  • I have added tests that render the full document and assert equality. While they are brittle, they allow to iterate much faster by seeing what's broken.
  • For context, checktyle / SpringLeadingWhitespace breaks when using space-indented text-blocks. There is an open issue in spring-javaformat ; //@formatter:off does not suppress the error. I have re-indented all text blocks with tabs. If we really prefer spaces, then we would need file-wide checkstyle suppressions. This is is Fixed in spring-javaformat 0.0.43

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 12, 2024
@Kehrlann Kehrlann force-pushed the default-ui-templates branch 2 times, most recently from 173a728 to 41411c5 Compare August 13, 2024 09:23
@Kehrlann Kehrlann marked this pull request as ready for review August 13, 2024 09:38
@Kehrlann Kehrlann force-pushed the default-ui-templates branch 2 times, most recently from 87ba3d0 to 7a2e673 Compare August 20, 2024 07:48
@Kehrlann Kehrlann force-pushed the default-ui-templates branch 4 times, most recently from 9363b22 to 1c4bc7a Compare August 27, 2024 14:29
Copy link
Member

@rwinch rwinch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I've left a few comments inline.

I also wonder if for the tests (that we have updated) if we can reduce the use of + and \n on the large Strings? I can understand the desire to avoid using the templates in the tests, but perhaps """ can still be used with minimal + of the variables. Alternatively, if we know the value of the variables we could just use a large constant there and assert that the value of the variables matches our constant.

margin: 0;
line-height: 1.5;
}
\s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious if there is a need for the \s escape sequence in the Strings? Is this related to the checkstyle problems?

Copy link
Contributor Author

@Kehrlann Kehrlann Aug 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost, the problem is the formatter, not checkstyle. Spring-javaformat deletes trailing spaces on lines, but not \s. Checkstyle does not complain.

Our text blocks do contain some blank lines with spaces, mostly due to calling .indent(...) on the CSS style blocks. So in our tests, we need to preserve the blank, non-empty lines in text-blocks. The vast majority will go away once we move the CSS out into a "static" resource.

@Kehrlann Kehrlann force-pushed the default-ui-templates branch 2 times, most recently from 0f060e5 to 3875dd1 Compare August 30, 2024 06:14
@Kehrlann Kehrlann requested a review from rwinch August 30, 2024 06:15
@Kehrlann
Copy link
Contributor Author

Addressed, using text blocks in tests too.

@rwinch rwinch merged commit ef31ae1 into spring-projects:main Sep 5, 2024
6 checks passed
@rwinch rwinch added in: web An issue in web modules (web, webmvc) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 5, 2024
@rwinch rwinch added this to the 6.4.0-M4 milestone Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web An issue in web modules (web, webmvc) type: enhancement A general enhancement
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants