Use of dot inside brackets is breaking the swig template

86 Views Asked by At

Use of Dot inside curly brackets is breaking the rendering of swig template. I am not sure if its a bug.

I have the code like this some where in between html text for a article:

<pre>
    <code>
        <span>new Promise (function  (resolve, reject) {...}  );</span>
    </code>
</pre>

Using dots inside brackets {...} is breaking the rendering. Why? When I remove it was working fine but I had to track down the issue.

1

There are 1 best solutions below

3
James Monger On

This is happening because { and } are reserved characters in Swig.

Swig will evaluate everything inside those characters, so it is trying to evaluate ..., which isn't a valid Swig expression.

You need to replace replace those characters with HTML entities to prevent Swig from evaluating them.

<pre>
    <code>
        <span>new Promise (function  (resolve, reject) &#123;...&#125;  );</span>
    </code>
</pre>