简体   繁体   中英

How to use reverse interpolation pug.js

I have a pug.js that has a good amount of code included in it. In order to write the block of code I have to write

pre #[code.language-python print("Hello!")]

I know that I can write a variable and use it like this:

- var codeMsg = 'Hello!'

h1 #{codeMsg}

but is there a way to use it so that I write a variable that contains the long tag declaration, and then put in my code? Like this:

myNewTag print("Hello!")

Thanks for any help!

You can combine a mixin withtag interpolation like this:

// mixin declaration
mixin python
  pre
    code.language-python
      block

// usage (don't forget the trailing dot)
+python.
  print("Hello, World!")
  print("Goodbye, World!")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM