Search code examples
escapingpugkeyword

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


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>