在pyjade解决方案中包括mixins [英] Including mixins in pyjade workaround

查看:117
本文介绍了在pyjade解决方案中包括mixins的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如github问题#70 所述,不支持包含混入./p>

有没有好的解决方法或替代解决方案?

解决方案

Pyjade的include实现不支持mixins,但扩展" 可以.因此,如果您只需要导入一个文件,该怎么办:

extends mixins.jade
block layout
  +link("example", "http://example.com/")

mixins.jade:

mixin link(text, url)
  a(href=url)= text

block layout

(回答我自己的问题,因为我在自己弄清楚这个问题之前进行了艰苦的搜索,并认为这可能对其他人有帮助)

As mentioned in the github issue #70 including mixins aren't supported.

Are there any good workarounds or alternative solutions?

解决方案

Pyjade's implementation of include doesn't support mixins, but "extends" does, although you have to use a "block". So what you could do if you just need to import one file:

extends mixins.jade
block layout
  +link("example", "http://example.com/")

mixins.jade:

mixin link(text, url)
  a(href=url)= text

block layout

(Answering my own question, because I searched hard before figuring this out myself and thought it could be helpful to others)

这篇关于在pyjade解决方案中包括mixins的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆