Frage

I'm trying to reproduce the basic example of the rebase function from the bottle documentation, but when my template is rendered the html code is encoded and my tags are replaced by their corresponding html code.

My template:

% rebase('base.tpl', title='Page Title')
<p>Page Content ...</p>

My base template:

<html>
<head>
  <title>{{title or 'No title'}}</title>
</head>
<body>
  {{base}}
</body>
</html>

The final html rendered:

<html>
<head>
  <title>Page Title</title>
</head>
<body>
      &lt;p&gt;Page Content ...&lt;/p&gt;

</body>
</html>

As you can see, my template is included at the right place, but it's like if the template engine had escaped it for security reasons and I don't know whys.

I'm surprised being the only one having this issue.

I'm using bottle v0.12.5 and reproduced the issue on different environnements (MacOSX & Ubuntu)

Any thoughts or ideas? Thanks

War es hilfreich?

Lösung

HTML special characters are automatically escaped. You can unescape them by adding a ! at the beginning of your expression:

<body>
  {{!base}}
</body>

You can see the documentation about this here.

Andere Tipps

I think;

The document of Bottle v0.12(stable) is not correct. Because it said {{ base }}. Bottle dev (development) is correct. Thus, {{ ! base }}

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top