Saturday, July 9, 2022

[FIXED] How to escape pug's keyword, such as when #{when}

Issue

we use pug to compile .pug file into .xml file.

one of xml file are using <when></when>

but when I try to add

p
   when #{when}

pug said when is keyword and syntax is error.

How could I escape keyword when in pug file as normal tag like h1 or p?


Solution

You can use interpolation, like this:

- let when = 'foo'
p
  #{'when'} #{when}

Which compiles to this:

<p>
  <when>foo</when>
</p>


Answered By - Sean
Answer Checked By - Willingham (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.