Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Templates disallow unescaped braces even after changing interpolation delimiters #14019

Closed
lazarljubenovic opened this issue Jan 19, 2017 · 7 comments

Comments

@lazarljubenovic
Copy link
Contributor

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

When interpolation delimiters are changed to [[ and ]], having an unescaped { in template still throws an error (including {{).

Expected behavior

{ should be allowed in templates if interpolation delimiters are changed.

Minimal reproduction of the problem with instructions

http://plnkr.co/edit/5Kl9w2Mpct9z7ljEgogS?p=preview

What is the motivation / use case for changing the behavior?

One would normally change interpolation string because one needs {{ for something else (eg. LaTeX syntax uses { heavily).

Please tell us about your environment:

  • Angular version: 2.4.x
  • Browser: all

  • Language: TypeScript

@lazarljubenovic
Copy link
Contributor Author

Upon further investigation, I realize that escaping { was introduced because of ICU messages. This was in 2.0.0-rc5 and interpolation was enabled in 2.0.0-rc3.

"{" is used a a delimiter for ICU messages then it could not be used in text nodes. "{" should be escaped as "{{ '{' }}"

Before:

<span>some { valid } text</span>

After:

<span>some { invalid } text<span> <!-- throw parse error -->
<span>some {{ '{' }} valid } text</span>

The original reason for allowing making interpolation strings configurable was to be able to type {{ without problems, but that's gone now too. It was mentioned that stuff might break with i18n in #8865, but looks like it was for other reasons (hardcoded braces).

@vicb
Copy link
Contributor

vicb commented Nov 28, 2017

We should update the error message to display the active delimiters instead of having {{ hardcoded

@ngbot ngbot bot added this to the Backlog milestone Jan 23, 2018
@trotyl
Copy link
Contributor

trotyl commented Aug 2, 2018

Duplicate of #11859

@Zefling
Copy link

Zefling commented Nov 12, 2018

Other strange case with braces. I want to escape double braces for show an example,

&#123;&#123; -50 | math:'min':50 &#125;&#125; show -50 and not {{ -50 | math:'min':50 }}

Currently, my solution, add a zero-width joiner (&#8205;):

&#123;&#8205;&#123; -50 | math:'min':50 &#125;&#125;

@lazarljubenovic
Copy link
Contributor Author

I've long given up trying to fit a { in a template. I just bind the string from the class now. 😄

@petebacondarwin
Copy link
Member

Yes @trotyl is right here - duplicate of #11859

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants