admin管理员组文章数量:1303335
I am planning to do a project with Vue in the frontend and Django in the backend, but they both use double curly braces {{ }}
as their template tags. Is there an easy way to change one of the two to use some other custom templating tag?
Thanks in advance.
I am planning to do a project with Vue in the frontend and Django in the backend, but they both use double curly braces {{ }}
as their template tags. Is there an easy way to change one of the two to use some other custom templating tag?
Thanks in advance.
Share asked Sep 18, 2020 at 1:43 Safwan SamsudeenSafwan Samsudeen 1,7072 gold badges12 silver badges27 bronze badges2 Answers
Reset to default 7Vue has a parameter called delimiters which set the placeholder's delimiters. For example this way you'll set them to double square brackets:
new Vue({
delimiters: ['[[', ']]'],
el: "#myapp",
//...
})
<div>
{{ djangoPlaceholder }}
[[ vuePlaceholderValue ]]
</div>
If you don't want to change the delimiters in Vue you can use the verbatim Django tag to prevent the braces from being interpreted:
{% verbatim %}
{{ myvuevar }}
{% endverbatim %}
This is a quick and simple approach that might suffice. It has the disadvantage that you cannot render Django variables within the verbatim tags (of course).
本文标签: javascriptVue and Django mustache templating conflictStack Overflow
版权声明:本文标题:javascript - Vue and Django mustache templating conflict - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741718621a2394259.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论