phug-php / phug

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

Output block unparsed? #112

Closed lensco closed 1 year ago

lensco commented 1 year ago

I'm working on a component library which has many examples, showing both the result and markup, written in pug. In order to avoid writing the same code twice, I made a mixin:

mixin styleguide-example
    .styleguide-example
        block
    pre: code.
        block

… but of course this outputs the literal text "block" in the code tag. If I leave off the dot I just get the actual parsed results. So is there an easy way to output the contents of a block without parsing?

kylekatarnls commented 1 year ago

Yes, you should follow this method: https://github.com/phug-php/phug/issues/79#issuecomment-1679565659

This can also likely be achieved by creating a custom component for that.

But as explained in the other issue, this project is a port of Pug-js and aims behave consistently.

lensco commented 1 year ago

Yeah, sorry for asking the same question two years later – forgot about that. I tried the component way, and I can't get it to work without repeating the whole code block/slot twice. Too bad I can’t just echo the original, unparsed block…