Skip to content

feat: add $for loop separator options#148

Merged
adamcavendish merged 1 commit into
masterfrom
adamcavendish/for-separator-trailing
Jun 20, 2026
Merged

feat: add $for loop separator options#148
adamcavendish merged 1 commit into
masterfrom
adamcavendish/for-separator-trailing

Conversation

@adamcavendish

@adamcavendish adamcavendish commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add separator = expr and trailing = bool options to $for
  • keep statement $for separators literal while adding true inline $for fragment joins
  • support multiline inline separators for union-style continuations, such as TypeScript | members
  • document the inline-vs-statement mental model and refresh macro feature examples
  • add coverage for inline unions, import tracking, trailing separators, statement separators, compound separators, and Go pointer spacing

Semantics

  • statement $for emits statement or block chunks and preserves their rendered newlines
  • inline $for acts like a join expression inside the surrounding statement
  • trailing = true repeats the same separator after the final non-empty iteration
  • empty loops emit no separator or trailing separator

Verification

  • cargo test
  • just lint
  • cargo run --example macro_features
  • mdbook build docs
  • mdbook test with an isolated CARGO_TARGET_DIR
  • git diff --check

@adamcavendish adamcavendish force-pushed the adamcavendish/for-separator-trailing branch from 4bd7a34 to 3a2ddf2 Compare June 19, 2026 11:26
@codecov-commenter

codecov-commenter commented Jun 19, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@adamcavendish adamcavendish force-pushed the adamcavendish/for-separator-trailing branch 4 times, most recently from bae2b6d to a0cdf2f Compare June 20, 2026 17:54
@adamcavendish adamcavendish changed the title feat: add for loop separator options feat: add $for loop separator options Jun 20, 2026
@adamcavendish adamcavendish force-pushed the adamcavendish/for-separator-trailing branch from a0cdf2f to c11da9d Compare June 20, 2026 18:43
- Parse separator and trailing=true options on `$for` loops.
- Keep statement `$for` separators literal and add inline `$for` fragment joins.
- Support multiline inline separators for TypeScript union-style continuations.
- Document separator semantics and update macro feature examples.
- Cover inline unions, import tracking, trailing separators, and Go pointer/multiplication spacing.
@adamcavendish adamcavendish force-pushed the adamcavendish/for-separator-trailing branch from c11da9d to 4d8e3fd Compare June 20, 2026 18:45
@adamcavendish adamcavendish merged commit 29d1515 into master Jun 20, 2026
8 checks passed
@adamcavendish adamcavendish deleted the adamcavendish/for-separator-trailing branch June 20, 2026 18:54
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.

2 participants