Prettier format template files#3084
Open
drgrice1 wants to merge 3 commits into
Open
Conversation
This uses the `@openwebwork/prettier-plugin-mojolicious-html-template` package to do so. That package is a `prettier` plugin that formats HTML with `prettier` and uses `perltidy` to format Perl content inside the Mojolicious template regions. The `@openwebwork/prettier-plugin-mojolicious-html-template` project repository is housed at https://github.com/openwebwork/prettier-plugin-mojolicious-html-template. I am giving ownership of the repository to webwork, because the project was developed with the usage of Claude code, and that usage was funded by the webwork project.
Member
Author
|
I forgot to mention the most important thing for developers. To format the template files you just do what you did before to format the JavaScript and css files. Execute |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
@openwebwork/prettier-plugin-mojolicious-html-templatepackage is aprettierplugin that formats HTML withprettierand usesperltidyto format Perl content inside the Mojolicious template regions.The
@openwebwork/prettier-plugin-mojolicious-html-templateproject repository is housed at https://github.com/openwebwork/prettier-plugin-mojolicious-html-template. I am giving ownership of the repository to webwork, because the project was developed with the usage of Claude code, and that usage was funded by the webwork project.So this is my first Claude powered pull request.
Note that the first commit adds the framework for using
prettierwith the plugin on template files, the second appliesprettierwith the plugin to all template files, and the third does some manual clean up. The manual clean up is mostly of strings in the help files because the new formatting ends up indenting them another level and makes the strings exceed the 120 character limit.I am targeting this to develop. There is certainly no urgency for adding this to the 2.21 release as it is a development only thing.
Note that the
bin/dev_scripts/pod-templates/main-index.mtfile is not formatted at this point. The.mtextension is not handled by the plugin, and is in fact not even a valid extension for a Mojolicious template file. That extension was introduced by @pstaabp at some point, and we just kind of went with it. Really any Mojolicious template file should have the extension.[output-format].epor.[output-format].eplwhere[output-format]is the type of file generated when the template is rendered. Note that a file rendered by theMojo::Templatepackage directly or rendered by theMojolicious::Plugin::EPLRenderer.pmpackage (which is just a thin wrapper around theMojo::Templatepackage) should use the.eplextension, and any rendered via theMojolicious::Plugion::EPRenderer.pmpackage should use the.epextension (this is how anything rendered by aMojolicious:Controlleris rendered). So thebin/dev_scripts/pod-templates/main-index.mtshould be ``bin/dev_scripts/pod-templates/main-index.html.epl`.Also, the
courses.dist/modelCourse/templates/achievements/notifications/default.html.epis incorrectly named. It should becourses.dist/modelCourse/templates/achievements/notifications/default.txt.ep(or reallycourses.dist/modelCourse/templates/achievements/notifications/default.txt.eplsince it is rendered viaMojo::Templatedirectly). This file certainly should not be formatted since it is not HTML, and the plugin only handles HTML template formatting. Text can't be formatted in any case (other than perhaps line wrapping). Due to thisFixing those file naming issues is left for later.