Skip to content

Formatter: ERB node in attribute position as the last node in an inline element followed by a text node is discarded #1771

Description

@dodecaphonic

Input:

<span <%= call(:me) %>>Foo</span> / Bar
<strong class="swole" <%= call(:me) %>>Bar</strong> / Baz

Output:

<span>Foo</span>
<strong>Bar</span>

Expected:

<span <%= call(:me) %>>Foo</span> / Bar <strong class="swole" <%= call(:me) %>>Bar</strong> / Baz

Playground:

https://herb-tools.dev/playground/?tab=format#DwZwDghgdgBMCkBeGBjCAbdAKAXAWwFMBKGeAPjIDEB7a4AenGjJnpgCEIAnAKFABcu1KAHNU6CCBCIARCADu1dARlwkqDNnzFSFTlwYhBwkSzacAXkA

Additional context:

  • It doesn't happen with block nodes.
  • However, if the inline node is followed by a block node, the erb content is emitted correctly:

Input

<strong <%= call(:me) %>>0</strong> / 2048 character limit

<div>
</div>

Output

<strong <%= call(:me) %>>0</strong>
/ 2048 character limit
<div></div>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions