简体   繁体   English

如何使用反向插值 pug.js

[英]How to use reverse interpolation pug.js

I have a pug.js that has a good amount of code included in it.我有一个 pug.js,其中包含大量代码。 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标签插值结合起来,如下所示:

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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