pyjade

Using python code in pyjade

China☆狼群 提交于 2020-01-03 16:51:11
问题 I'm trying to generate a list using pyjade, like so: ul - for i, (label, link) in enumerate(tabs) li(class="selected" if i == selected_index else "") a(href=link)= label But I see this error: UndefinedError: 'enumerate' is undefined I must be embedding python code into Jade wrong. What's the right way to do this? 回答1: Jade uses what I refer to as "implicit enumeration" - it enumerates values in a list simply by adding one more variable, i , than there are values to unpack: for item, i in list

Using python code in pyjade

核能气质少年 提交于 2020-01-03 16:48:21
问题 I'm trying to generate a list using pyjade, like so: ul - for i, (label, link) in enumerate(tabs) li(class="selected" if i == selected_index else "") a(href=link)= label But I see this error: UndefinedError: 'enumerate' is undefined I must be embedding python code into Jade wrong. What's the right way to do this? 回答1: Jade uses what I refer to as "implicit enumeration" - it enumerates values in a list simply by adding one more variable, i , than there are values to unpack: for item, i in list

Including mixins in pyjade workaround

大兔子大兔子 提交于 2019-12-10 15:44:30
问题 As mentioned in the github issue #70 including mixins aren't supported. Are there any good workarounds or alternative solutions? 回答1: 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