Skip to content

Conversation

@NullVoxPopuli
Copy link
Contributor

RFC: emberjs/rfcs#1121

Criteria / Algo:

  • The leading and trailing invisible characters for opening <template> and closing </template> in gjs/gts files should be stripped.
    • This helps determine the "indentation level" which would also be stripped from each line -- effectively de-denting templates to what developers were used to before we started embedding templates in JS/TS.
    • How to determine indentation:
      • scan all lines after the line with <template> and before the line with </template>
        • ignore content on the same line as the opening and closing template tags
      • indentation is determined by the smallest number of invisible characters for each line
        • skip lines with 0 characters
        • ideally all other lines have the same or greater indentation
        • if spaces and tabs are mixed, we can ignore tabs -- we don't do any indentation stripping
        • stripping tab indentation can only happen if all lines are indented with tabs

@NullVoxPopuli NullVoxPopuli changed the title Failing tests for: indentation stripping indentation stripping Nov 24, 2025
@NullVoxPopuli
Copy link
Contributor Author

NullVoxPopuli commented Nov 24, 2025

Disclaimer: I don't know rust -- please review carefully

Copy link

Copilot AI commented Nov 24, 2025

@NullVoxPopuli I've opened a new pull request, #113, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements indentation stripping for <template> tags in .gjs/.gts files as specified in RFC #1121. The feature automatically removes leading/trailing whitespace and common indentation from embedded templates, allowing developers to write naturally indented code that compiles to properly dedented templates.

Key changes:

  • Added strip_indent() function in Rust to calculate and remove common indentation
  • Modified template content processing to apply indentation stripping before compilation
  • Added comprehensive test coverage for various indentation scenarios including opt-out behavior

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/transform.rs Core implementation of strip_indent() function and integration into template content processing
src/lib.rs Integration tests for basic indentation stripping scenarios
test/node/process.test.js Comprehensive test suite covering edge cases and RFC compliance

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@NullVoxPopuli NullVoxPopuli marked this pull request as ready for review November 24, 2025 06:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ef4 ef4 merged commit 2a065bb into main Nov 25, 2025
1 check passed
@ef4 ef4 deleted the nvp/indentation-stripping branch November 25, 2025 16:22
@NullVoxPopuli NullVoxPopuli added the enhancement New feature or request label Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants