Skip to content

Newline & indentation causing issues in interpreted spaces #10924

Closed
@duckness

Description

@duckness

Version

2.6.10

Reproduction link

https://jsbin.com/feloyenami/2/edit?html,js,output

Steps to reproduce

Have any code written with the following format (including indentation and newlines)

<div>
  <span>span</span>
  <a 
    href="https://example.com"
    rel="s"
  >
    {{ "MESSAGE" }}
  </a>
  <span>span</span>
</div>

What is expected?

Consistent rendering of the middle element, and without spaces.

What is actually happening?

On node, the dev mode and built files will be rendered as:

node

Including Vue as a script tag (like in the repro), you will get:

html

However, what you probably really want is:

want


Personally, I feel that whitespace should be stripped out if the curly braces are the only thing within the html tag, if those are required then they can be added within the curly braces like {{ " example " }}.

You will probably encounter this if you use plugin:vue/recommended in your eslint config as that enforces the multi-line attributes in html tags.

Workaround:

<span>span</span>
<a 
  href="https://example.com"
  rel="s"
>
  <template>{{ "MESSAGE" }}</template>
</a>
<span>span</span>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions