Gratuitous string concatenation occurs when escaped curly braces are present
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 54
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
The output is less than ideal when \{ and \} are present -- there is additional string concatenation going on in the compiled function that is pretty ugly:
Template:
\{\{Outer with data\}\} {{data.name}}
<code>
\{\{Nested\}\}
</code>
<code>
\{\{Nested with data\}\} {{data.name}}
</code>
Output:
(function anonymous(data_0) {
var frag = document.createDocumentFragment();
var data = data_0;
var el0 = document.createTextNode("{"+"{"+"Outer with data"+"}"+"}"+" "+data_0["name"]+"\n\n");
frag.appendChild(el0);
var el1 = document.createElement("code");
el1.textContent = "\n "+"{"+"{"+"Nested"+"}"+"}"+"\n";
frag.appendChild(el1);
var el2 = document.createTextNode("\n\n");
frag.appendChild(el2);
var el3 = document.createElement("code");
el3.textContent = "\n "+"{"+"{"+"Nested with data"+"}"+"}"+" "+data_0["name"]+"\n";
frag.appendChild(el3);
return frag;
})
The parser could be modified to concatenate the braces into an existing content block instead of creating a new one, or DOMly could be fixed to combine content blocks into a single string instead of concatenating multiple strings.
This is due to the fixes for #7. @cif
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the parser and DOMly content-block handling affected by the fixes for #7; the issue does not name specific files or tests. Use the provided escaped-brace template and compiled output as the regression case, and consider both suggested implementation areas. Done means the generated function avoids gratuitous string concatenation while preserving the escaped braces and interpolated data.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100