Gratuitous string concatenation occurs when escaped curly braces are present
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 38/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript
- 领域
- frontend
调研方向
首先追踪受 #7 修复影响的 parser 和 DOMly content-block 处理;该 issue 未指定具体文件或测试。使用提供的带有 escaped braces 的模板和编译后的输出作为回归用例,并考虑建议的两个实现方向。完成的标准是生成的函数避免不必要的字符串拼接,同时保留 escaped braces 和插值数据。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- JavaScript
- 星标
- 54
- 派生
- 9
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
lazd/DOMly 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
-
难度 5/5 一周以上 新手友好度 25/100
-
DOMly chokes on function calls with strings that contain braces {x}可能重新可做 @lazd 于 3693 天前认领,目前没有进行中的 PR。 未关闭
-
enhancement
难度 3/5 1-2 天 新手友好度 52/100
-
难度 4/5 3-5 天 新手友好度 25/100
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 78/100
521xueweihan/HelloGitHub#4237 ·
-
enhancement localization
难度 2/5 1-3 小时 新手友好度 65/100
quarto-dev/quarto-cli#15268 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
-
难度 1/5 1 小时以内 新手友好度 72/100
oarepo/oarepo-ui#512 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 2 天内回复