[英]How can I pass this string through thymeleaf th:replace?
Originally my index.html looked like this: 最初,我的index.html看起来像这样:
<div data-bind="attr: {id: 'newsEntry_'+ $parentContext.$index() +'_lead_' + $index() + '_toolbar'}">
...
</div>
which works! 哪个有效!
I separated that part to an external edit.html file and includet it with thymeleafs th:replace to my index.html: 我将该部分分离到一个外部edit.html文件中,并将其与百里香th:replace一起包含到我的index.html中:
<div th:replace="fragments/editor :: editor(binding='data-bind=\'attr: {id: \'newsEntry_\'+ $parentContext.$index() +\'_lead_\' + $index() + \'_toolbar\'}\'')" >...</div>
fragments/editor.html: fragment / editor.html:
<div th:fragment="editor(binding)">
<div th:attr="${binding}">...</div>
</div>
I get this error: 我收到此错误:
org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as assignation sequence: "${binding}" (fragments/editor:9) org.thymeleaf.exceptions.TemplateProcessingException:无法解析为分配序列:“ $ {binding}”(片段/编辑器:9)
data-bind is the binding from knockout.js. 数据绑定是来自基因敲除.js的绑定。
I think the error is something with the escpaing of " ' \\' 我认为错误在于“'\\”
I got it: 我知道了:
index.html: index.html:
<div th:replace="fragments/editor :: editor(binding='attr:{ id: \'newsEntry_\'+ $parentContext.$index() +\'_lead_\' + $index() + \'_toolbar\'}')" >...</div>
editor.html: editor.html:
<div th:fragment="editor(binding)">
<div th:attr="data-bind=${binding}"></div>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.