phug-php / phug

Phug - The Pug Template Engine for PHP
https://phug.selfbuild.fr
MIT License
63 stars 3 forks source link

Variable is printing twice #77

Closed trentwiles closed 4 years ago

trentwiles commented 4 years ago

Content is output twice with:

#{content}

From: https://stackoverflow.com/questions/64861822/phug-php-variable-is-printing-twice

kylekatarnls commented 4 years ago

What you see is #{content} which is a dynamic tag:

- content = 'div'
#{content} Foo

(same in Phug or Pug.js)

renders:

<div>Foo</div>

To insert a variable as raw html content, you simply need:

!=content

Or first a text node:

| !{content}

Note than you shouldn't use htmlspecialchars if you already escape in the template: | #{content} is escaped, | !{content} is displayed raw, =content is escaped, !=content is raw.

trentwiles commented 4 years ago

Thank you!