0

I am using twig as below

res.render("screen/index.twig", {
    name: 'word',
    columns: columns,
});

It is working as excepted.

Now I want to switch to twing and used below code

const contents = await twing
.render("screen/index.twig", {
  name: 'word',
  columns: columns,
})
res.end(contents);

here contents give below

...
  <script>
    window.COLUMNS = [{&quot;alignment&quot;:&quot;left&quot;}];
  </script>
...

But I need the below output without using any .replace function. How can I achieve this? Can anyone tell why it working in twig and not in twing? Thanks.

...
  <script>
    window.COLUMNS = [{"alignment":"left"}];
  </script>
...
Eric MORAND
  • 6,373
  • 4
  • 27
  • 34
Benk I
  • 185
  • 13
  • 1
    Please post the actual template, `index.twig`! As far as I can see you're missing the filter `raw`, but can't tell w/out seeing the template – DarkBee Dec 14 '21 at 07:38
  • Yes. `raw` is missing. i.e. I have changed `window.COLUMNS = {{ columns | json_encode()}};` to `window.COLUMNS = {{ columns | json_encode() | raw}};` in `index.twig` and the `"` is gone. Thanks. But why raw is not needed in twig? i.e. Why does Twig not have this problem? Why is Twing not doing this automatically? – Benk I Dec 14 '21 at 08:36
  • I'm not sure which version you were testing this on, but it is needed in `twig` as well - [demo](https://twigfiddle.com/6501q0) – DarkBee Dec 14 '21 at 08:55
  • @DarkBee please check this question once and help me to solve the same. Thanks once again. https://stackoverflow.com/questions/70346658/how-to-use-direct-path-of-file-without-declaring-folder-path-twing – Benk I Dec 14 '21 at 09:36

0 Answers0