简体   繁体   English

W3.JS 在 Octobercms 页面或部分显示 HTML 数据 {{variable}}

[英]W3.JS Display HTML Data {{variable}} in Octobercms Page or Partial

please help me with October CMS Code - Page or Partial, how to use them with W3.JS.请帮助我提供十月 CMS 代码 - 页面或部分,如何将它们与 W3.JS 一起使用。

W3.JS Display HTML Data {{variable}} in Octobercms W3.JS 显示 HTML 数据 {{variable}} in Octobercms

{{ }} this transcription use OctoberCMS for your own data {{ }} 此转录将 OctoberCMS 用于您自己的数据

But W3.JS Display HTML Data use the same transcription但是 W3.JS 显示 HTML 数据使用相同的转录

https://www.w3schools.com/w3js/w3js_display.asp https://www.w3schools.com/w3js/w3js_display.asp

<div id="id01">
{{firstName}} {{lastName}}
</div>

<script>
var myObject = {"firstName" : "John", "lastName" : "Doe"};
w3.displayObject("id01", myObject);
</script>

it doesn't work它不起作用

thank you for your help谢谢您的帮助

Vasek瓦塞克

Wrap the JavaScript template part in verbatim filter: https://twig.symfony.com/doc/3.x/templates.html#escapingverbatim过滤器中包装 JavaScript 模板部分: https://twig.symfony.com/doc/3.x/templates.html#escaping

It's very simple you just make it string so TWIG will treat it as a string and do not parse/interpolate it.这很简单,您只需将其设为字符串,因此 TWIG 会将其视为字符串并且不会对其进行解析/插值。

<div id="id01">
{{ '{{firstName}} {{lastName}}' }}
</div>

<script>
var myObject = {"firstName" : "John", "lastName" : "Doe"};
w3.displayObject("id01", myObject);
</script>

{{ '{{firstName}} {{lastName}}' }} -> it will output {{firstName}} {{lastName}} in final markup {{ '{{firstName}} {{lastName}}' }} -> 最终标记中会出现 output {{firstName}} {{lastName}}

if any doubt please comment如有任何疑问,请发表评论

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM