Home > Blockchain >  W3.JS Display HTML Data {{variable}} in Octobercms Page or Partial
W3.JS Display HTML Data {{variable}} in Octobercms Page or Partial

Time:12-31

please help me with October CMS Code - Page or Partial, how to use them with W3.JS.

W3.JS Display HTML Data {{variable}} in Octobercms

{{ }} this transcription use OctoberCMS for your own data

But W3.JS Display HTML Data use the same transcription

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

CodePudding user response:

Wrap the JavaScript template part in verbatim filter: https://twig.symfony.com/doc/3.x/templates.html#escaping

CodePudding user response:

It's very simple you just make it string so TWIG will treat it as a string and do not parse/interpolate it.

<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

if any doubt please comment

  • Related