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

Add an escape sequence to avoid polymer to bind the content of brackets #3529

Closed
wants to merge 2 commits into from

Conversation

theboolean
Copy link

Refs googlearchive/TemplateBinding#186

This PR is a proposal to add the possibility to escape the brackets without binding the content.
If this kind of behaviour is acceptable, I would be glad to write also unit tests.

Usage:

{{test}}: normal behaviour
{{\test}}: don't bind to test and print literal {{test}}
{{\\test}}: don't bind to test and print literal {{\test}}
and so on... always remove one of the backslashes

[[test]]: normal behaviour
[[\test]]: don't bind to test and print literal [[test]]
[[\\test]]: don't bind to test and print literal [[\test]]
and so on... always remove one of the backslashes

@dfreedm
Copy link
Member

dfreedm commented Mar 25, 2016

This seems reasonable to me. Can you add a test case?

@theboolean theboolean force-pushed the add-escape-sequence branch from 533ed7b to 7a86003 Compare May 10, 2017 20:54
@theboolean
Copy link
Author

@azakus sorry for the huuuge delay, I finally wrote tests you asked. I also rebased the history on the current master branch, so the feature is available for Polymer 2.0 and the PR can be automatically merged.

@TimvdLippe
Copy link
Contributor

After a discussion about this PR, we decided to not include this functionality, mainly because of performance concerns. You can override _parseBindings in your element to implement escaping in the spots you want this feature, which means that regular applications or other elements do not regress.

@TimvdLippe TimvdLippe closed this Sep 14, 2017
@warpech
Copy link

warpech commented Jul 25, 2018

Simple workaround that works in HTML without any overwriting of _parseBindings:

Whenever you want to write {{something}} on your page, and force Polymer to skip parsing that, put a HTML comment somewhere inside of it, e.g.

{<!-- This comment is needed to prevent Polymer from parsing curly braces -->{something}}

Tested with Polymer 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants