question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Whitespace injection after variable interpolation

See original GitHub issue

vue & vue-i18n version

vue: 2.5.21, vue-i18n: 8. 7. 0

Reproduction Link

Steps to reproduce

Using advanced interpolation, we have this i18n tag

<i18n
      path="HOME.INTRODUCTION.CERTIFICATE_INFO"
      tag="p"
      class="introduction"
    >
      <span place="userName">
        {{ userName }}
      </span>
      <strong
        class="highligth-text"
        place="baseCertificate"
      >
        {{ $t('HOME.INTRODUCTION.BASE_CERTIFICATE') }}
      </strong>
      <strong
        class="highligth-text"
        place="personalizedCertificate"
      >
        {{ $t('HOME.INTRODUCTION.PERSONALIZED_CERTIFICATE') }}
      </strong>
    </i18n>

And this language object

export const es = {
  HOME: {
    INTRODUCTION: {
      TITLE: 'Necesito un certificado',
      CERTIFICATE_INFO:
        'Hola {userName}, desde aquí podras generar',
      BASE_CERTIFICATE: 'certificado base',
      PERSONALIZED_CERTIFICATE: 'certificado personalizado'
    },
    SUBTITLE: 'Selecciona que tipo de certificado quieres generar para ti.'
  }
}

What is Expected?

In the CERTIFICATE_INFO interpolation we expect that the component just not inject a white space after the variable in brackets.

Hola Frederick, desde aquí....

What is actually happening?

Actually, the library is adding a white space after the variable in brackets.

Hola Frederick , desde aquí....

Comment

I guess, this could be a nice behaviour, but the interpolation should detect if the next character is a dot or a comma

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kazuponcommented, Feb 26, 2019

Sorry, late for a reply 🙇

This is due to the behavior of Vue’s template compiler. You need to remove the space.

  • before
<span place="userName">  {{ "Carlos" }}  </span>
  • after
<span place="userName"> {{ "Carlos" }} </span>
0reactions
belvederefcommented, Jun 1, 2021

Related to #623 and #963, seems like the only solution is to trim whitespace in some way external to this project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

use a variable with whitespace Perl - Stack Overflow
No, since the default glob() delimits with white space. use File::Glob qw{ :bsd_glob ); to replace the default with one that allows white...
Read more >
String interpolation - CloudBees Documentation
Groovy string interpolation can inject rogue commands into command interpreters via special characters. Using Groovy string interpolation for user-controlled ...
Read more >
Interpolation - Pug
The tag interpolation syntax is especially useful for inline tags, where whitespace before and after the tag is significant. By default, however, Pug...
Read more >
bash - How to send a command with arguments without spaces?
Consecutive separator characters that are whitespace are treated as a single separator, so the result of the expansion of cat${IFS}file.txt is ...
Read more >
string interpolation - format string output - Microsoft Learn
To identify a string literal as an interpolated string, prepend it with the $ symbol. You can't have any white space between the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found