nebulab / erb-formatter

Format ERB files with speed and precision
MIT License
135 stars 22 forks source link

Format most ERB block open statements #57

Open pelletencate opened 2 months ago

pelletencate commented 2 months ago

Previously, whenever a block is being opened, we assume we can't format them because a SyntaxTree can't be established based on an unended block.

This PR attempts to resolve that for most blocks by doing the following:

  1. If it's a do block: assume you get a valid Ruby statement if you remove the terminating do or { and the parameter list
  2. If it's an if, unless, while or until block: assume you get a valid Ruby expression if you remove the first word (if/unless/while/until).

This will successfully format most blocks open statements.

Dependencies: