Skip to content

Always end template files in a newline#3687

Merged
raphael merged 4 commits into
goadesign:v3from
MichaelUrman:template-newlines
Apr 1, 2025
Merged

Always end template files in a newline#3687
raphael merged 4 commits into
goadesign:v3from
MichaelUrman:template-newlines

Conversation

@MichaelUrman
Copy link
Copy Markdown
Contributor

For most templates this works fine. For a few templates, this throws off whitespace.

  • Address several by tweaking the partial meta-template in http/codegen/templates.go to trim leading and trailing whitespace. For reasons unexplored, this does not appear to be necessary in grpc or root templates.
  • Address some more by stripping trailing whitespace in the template itself
  • Address remainder by tweaking golden expectations around main (add empty lines before var(){} blocks)

fixes #3681

MichaelUrman and others added 4 commits March 31, 2025 14:14
- Remove spurious newline in parse_endpoint
- Update test (leave trailing whitespace alone)
- request_init.go.tpl needs to strip it
- Most partials need to strip, but handle once inside templates.go
- codegen/service/templates/return_type_init.go.tpl removes this with a
  trailing dash, as the say it's consumed through validations is hard to
  follow and fix
- example now spaces out before var(){} blocks including after flag.Parse()
@raphael
Copy link
Copy Markdown
Member

raphael commented Apr 1, 2025

This is something that had been in the back of my mind for a long time now - really appreciate the contribution!

@raphael raphael merged commit 7444b7a into goadesign:v3 Apr 1, 2025
13 checks passed
@MichaelUrman MichaelUrman deleted the template-newlines branch April 1, 2025 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generated gRPC comments are merged with prior closing brace

2 participants