我想做类似的事情:我有一个生成css链接的mixin,我想在模板文件中声明它,我想在主jade文件中声明mixins的参数。
mixin includeCss(...cssFiles)
each file in cssFiles
link(rel="stylesheet", href=file)
doctype html
html(lang="en")
head
+includeCss(cssIncludes)
extends ./layouts/template
- var cssIncludes = ["style.css", "style2.css"]
答案 0 :(得分:0)
在Jade,you need to use block
for proper inheritance。所以你应该使用这样的东西。否则,您放在index.jade中的任何内容都不会被转移回扩展内容。
block vars
doctype html
html(lang="en")
head
+includeCss(cssIncludes)
extends ./layouts/template
block vars
- var cssIncludes = ["style.css", "style2.css"]