-
Notifications
You must be signed in to change notification settings - Fork 1
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
[AUT-3670] fix: removing hb special symbols around placeholder #404
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -127,7 +127,10 @@ var Container = Element.extend({ | |||||||||||||||||||||||
//@todo : container rendering merging, to be tested | ||||||||||||||||||||||||
tpl = tpl.replace(elt.placeholder(), elt.render(renderer)); | ||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||
tpl = tpl.replace(elt.placeholder(), '{{{' + serial + '}}}'); | ||||||||||||||||||||||||
tpl = tpl | ||||||||||||||||||||||||
.replace(elt.placeholder(), serial) | ||||||||||||||||||||||||
.replace('{', '{') | ||||||||||||||||||||||||
.replace(serial, '{{{' + serial + '}}}'); | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: The temporary replacement with the final value for transforming the remaining keywords is not robust as this final value may exist in other places. I'd rather suggest an approach where possible collision is avoided. Moreover, the Regarding the placeholder replacer, one could do this:
Suggested change
However, it will still create issues when having multiple elements in the same template, See: And with the original proposed solution: thought: I'm not sure we can replace all braces this way. An approach would be to rewrite the loop, splitting it in several occurrences: a first loop to remove the elements with robust placeholders, another loop to neutralize the braces, and finally a last loop to replace back elements with their serial... I'll let you figure out the implementation of this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for suggestions. I changed a bit approach of replacing. |
||||||||||||||||||||||||
elementsData[serial] = elt.render(renderer); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought: if
'{'
is a{
sign - can we use a standard HTML entity for this:'{'
and possibly use the regular expression in order to match all occurrences:
.replace(/\{/g, '{')
.Could you please test if it will work in your case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought: I'm not sure
{
is better than{
. It is less readable. The numeric version is acceptable when replacing chars with entities using their Unicode value without bothering about a dictionary. But I'd rather suggest, whenever possible, to always use the named entities for the sake of readability.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch regarding single occurrence, but HB parse brokes only first open brace in the begin of placeholder, other
{
can be ignored.Agreed with @jsconan
{
is more readable