You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue
Assume you need to set the literal value [[WIP]] to an element's property (or an attribute).
Due to the "square-brace" syntax ([[]]), the following code does not work:
<my-elementtitle="[[WIP]]"></my-element>
The reason is that the annotation parser treats [[WIP]] as an annotation for data binding.
Currently, I have not found any documented way to escape the “square-brace” / “curly-brace” syntax. I just found this TODO:
// TODO(kschaaf): We could modify this to allow an escape mechanism by// looking for the escape sequence in each of the matches and converting// the part back to a literal type, and then bailing if only literals// were found
_parseBindings: function(text){
Use cases
Escaping annotation can be very useful when you work with server-side generated HTML, or when you need to pass a JSON serialised string, for example:
It works because template has the serialize method that does nothing when the input is a String, as documented here, and so the first passed param is returned untouched.
Questions
I don't think that it's a definitive solution but I would like to know:
Is it an acceptable way to escape the annotation syntax?
Is there a better way to escape the annotations?
Or will it be available in next release?
Currently, I'm just trying to understand which is the best approach for this use case.
I used the [[..]] syntax as example, but it works for {{..}} too
This workaround could also work for googlearchive/TemplateBinding#186
The text was updated successfully, but these errors were encountered:
leogr
changed the title
Workaround/solution for escaping double-escaped annotations
Workaround for escaping annotations with “square-brace” / “curly-brace” syntax
Mar 22, 2016
@leogr was correct that that PR was intended to implement this. However, we decided to not configure this globally. Rather you can implemented this functionality yourself in _parseBindings. For more info see #3529 (comment)
Issue
Assume you need to set the literal value
[[WIP]]
to an element's property (or an attribute).Due to the "square-brace" syntax (
[[]]
), the following code does not work:The reason is that the annotation parser treats
[[WIP]]
as an annotation for data binding.Currently, I have not found any documented way to escape the “square-brace” / “curly-brace” syntax. I just found this TODO:
Use cases
Escaping annotation can be very useful when you work with server-side generated HTML, or when you need to pass a JSON serialised string, for example:
Workaround
But I found a working workaround doing so:
It works because
template
has theserialize
method that does nothing when the input is aString
, as documented here, and so the first passed param is returned untouched.Questions
I don't think that it's a definitive solution but I would like to know:
Currently, I'm just trying to understand which is the best approach for this use case.
The text was updated successfully, but these errors were encountered: